-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
63 lines (56 loc) · 2.81 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
podTemplate(label: 'label', cloud: 'openshift', serviceAccount: 'kabanero-operator', containers: [
containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl', ttyEnabled: true, command: 'cat',
envVars: [ envVar(key: 'TAG', value: 'v3'),
envVar(key: 'B_TAG', value: 'v4'),
envVar(key: 'IMAGENAME', value: 'dnb-transaction'),
envVar(key: 'B_APP', value: 'dnb-transaction-staging'),
envVar(key: 'PROJECT', value: 'cpfa-dnb')])
]){
node('label') {
stage('Deploy to dev') {
container('kubectl') {
checkout scm
sh 'sed -i -e \'s#applicationImage: .*$#applicationImage: docker-registry.default.svc:5000/\'$PROJECT\'/\'$IMAGENAME\':\'$TAG\'#g\' app-deploy.yaml'
sh 'cat app-deploy.yaml'
sh 'find . -name app-deploy.yaml -type f|xargs kubectl apply -f'
}
}
stage('Run Automation Test') {
container('kubectl') {
sh 'echo Automation_Test_Success'
}
}
stage('Promote to Test?') {
container('kubectl') {
sh 'echo Promote'
}
}
stage('Canary release') {
container('kubectl') {
checkout scm
sh 'sed -i -e \'s#applicationImage: .*$#applicationImage: docker-registry.default.svc:5000/\'$PROJECT\'/\'$IMAGENAME\':\'$B_TAG\'#g\' app-deploy.yaml'
sh 'sed -i -e \'s#name: .*$#name: \'$B_APP\'#g\' app-deploy.yaml'
sh 'sed -i -e \'s#host: .*$#host: \'$B_APP\'-cpfa-dnb.mcmhub-demo01-32d7c19d4374c7b6f6308b1ef2de3e3e-0001.us-east.containers.appdomain.cloud#g\' app-deploy.yaml'
sh 'cat app-deploy.yaml'
sh 'find . -name app-deploy.yaml -type f|xargs kubectl apply -f'
sh "kubectl get routes"
}
}
stage('Set A-B Route') {
container('kubectl') {
openshift.withCluster() {
openshift.withProject() {
echo "Using project: ${openshift.project()}"
}
//def route = openshift.selector("routes", "dnb-transaction") //(1)
//println "Route: ${route}"
//def routeObj = route.object()
//println "Route: ${routeObj}"
//routeObj.spec.alternateBackends = []
//routeObj.spec.alternateBackends[0] = ["kind": "Service","name": "${B_APP}", "weight": 60] //(2)
//openshift.apply(routeObj) //(3)
}
}
}
}
}