-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.all
54 lines (43 loc) · 1.29 KB
/
Jenkinsfile.all
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
pipeline {
agent any
options {
timeout(time: 2, unit: 'MINUTES')
}
environment {
ARTIFACT_ID = "elbuo8/webapp:${env.BUILD_NUMBER}"
}
stages {
stage('Building image') {
steps{
sh '''
docker build -t testapp .
'''
}
}
stage('Run tests') {
steps {
sh "docker run testapp npm test"
}
}
stage('Deploy Image') {
steps{
sh '''
docker tag testapp 127.0.0.1:5000/mguazzardo/testapp
docker push 127.0.0.1:5000/mguazzardo/testapp
'''
}
}
stage('Pass To K8s'){
steps {
sh '''
sshpass -p 'master' ssh 172.17.0.1 -l root -o StrictHostKeyChecking=no "kubectl create deployment testapp --image=127.0.0.1:5000/mguazzardo/testapp"
echo "Wait"
sleep 10
sshpass -p 'master' ssh 172.17.0.1 -l root -o StrictHostKeyChecking=no "kubectl expose deployment testapp --port=3000"
sshpass -p 'master' ssh 172.17.0.1 -l root -o StrictHostKeyChecking=no "wget https://raw.githubusercontent.com/tercemundo/platzi-scripts-integracion/master/webapp/nodePort.yml"
sshpass -p 'master' ssh 172.17.0.1 -l root -o StrictHostKeyChecking=no "kubectl apply -f nodePort.yml"
'''
}
}
}
}