-
Notifications
You must be signed in to change notification settings - Fork 109
/
Jenkinsfile
46 lines (43 loc) · 1.29 KB
/
Jenkinsfile
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
node('slave1'){
def svcName = 'products'
def nsName = "${svcName}-testing-${env.BUILD_NUMBER}"
stage ('git'){
checkout scm
}
def image = ''
stage ('dockerize'){
image = docker.build "otomato/oto-${svcName}:${env.BUILD_NUMBER}"
}
stage ('push'){
image.push()
}
def APP_URL=''
stage ('deploy-to-testing'){
sh "sed -i -- \'s/BUILD_NUMBER/${env.BUILD_NUMBER}/g\' ${svcName}-dep.yml"
sh "kubectl create namespace ${nsName}"
sh "kubectl apply -f mongodep.yml --validate=false -n ${nsName}"
sh "kubectl apply -f ${svcName}-dep.yml --validate=false -n ${nsName}"
//get app url
APP_URL = "<pending>"
sleep 120
while ( APP_URL == "<pending>"){
APP_URL = sh returnStdout: true, script: "kubectl get svc ${svcName} --no-headers=true -n ${nsName} | awk '{print \$4}'"
APP_URL = APP_URL.trim()
}
echo "url is ${APP_URL}"
}
stage ('component-test'){
withEnv(["APP_URL=${APP_URL}"]) {
sh "tests/ct/run.sh"
}
}
stage ('clean-up'){
sh "kubectl delete ns ${nsName}"
}
stage('deply-to-staging'){
sh "kubectl apply -f ${svcName}-dep.yml -n staging"
}
stage ('integration-test'){
echo "Not implemented"
}
}