-
Notifications
You must be signed in to change notification settings - Fork 407
/
Copy pathJenkinsfile
50 lines (48 loc) · 2.42 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
@Library('dynatrace@master') _
def tagMatchRules = [
[
meTypes: [
[meType: 'SERVICE']
],
tags : [
[context: 'CONTEXTLESS', key: 'environment', value: 'production']
]
]
]
pipeline {
agent {
label 'kubegit'
}
stages {
stage('Update production versions with latest versions from staging') {
steps {
container('kubectl') {
sh "sed -i \"s#image: .*#image: `kubectl -n staging get deployment -o jsonpath='{.items[*].spec.template.spec.containers[0].image}' --field-selector=metadata.name=carts`#\" carts.yml"
sh "sed -i \"s#image: .*#image: `kubectl -n staging get deployment -o jsonpath='{.items[*].spec.template.spec.containers[0].image}' --field-selector=metadata.name=catalogue`#\" catalogue.yml"
sh "sed -i \"s#image: .*#image: `kubectl -n staging get deployment -o jsonpath='{.items[*].spec.template.spec.containers[0].image}' --field-selector=metadata.name=front-end`#\" front-end.yml"
sh "sed -i \"s#image: .*#image: `kubectl -n staging get deployment -o jsonpath='{.items[*].spec.template.spec.containers[0].image}' --field-selector=metadata.name=orders`#\" orders.yml"
sh "sed -i \"s#image: .*#image: `kubectl -n staging get deployment -o jsonpath='{.items[*].spec.template.spec.containers[0].image}' --field-selector=metadata.name=payment`#\" payment.yml"
sh "sed -i \"s#image: .*#image: `kubectl -n staging get deployment -o jsonpath='{.items[*].spec.template.spec.containers[0].image}' --field-selector=metadata.name=queue-master`#\" queue-master.yml"
sh "sed -i \"s#image: .*#image: `kubectl -n staging get deployment -o jsonpath='{.items[*].spec.template.spec.containers[0].image}' --field-selector=metadata.name=shipping`#\" shipping.yml"
sh "sed -i \"s#image: .*#image: `kubectl -n staging get deployment -o jsonpath='{.items[*].spec.template.spec.containers[0].image}' --field-selector=metadata.name=user`#\" user.yml"
sh "kubectl -n production apply -f ."
}
}
}
stage('DT Deploy Event') {
steps {
container("curl") {
script {
def status = pushDynatraceDeploymentEvent (
tagRule : tagMatchRules,
customProperties : [
[key: 'Jenkins Build Number', value: "${env.BUILD_ID}"],
[key: 'Git commit', value: "${env.GIT_COMMIT}"]
]
)
}
}
}
}
}
}