-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
63 lines (56 loc) · 1.92 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
library 'jenkins-utils'
node("k8s") {
stage("Checkout") {
checkout scm
}
stage("Build") {
sh("make build")
}
stage("Release") {
sh("make release")
}
if (!env.BRANCH_NAME.equals("main")) {
stage("Deploy") {
k8s_contexts = [
"staging",
"datastores-us-central1"
]
// getKubeconfig() is needed to get authentication to the k8s clusters
getKubeconfig()
// withRepoKey is needed in order to decrypt ecfg-encrypted secrets.
// If you don't have secrets, you don't need this. But it wont break
// anything to include it anyway.
withRepoKey {
k8s_contexts.each { cluster ->
template(
basedir: "${env.WORKSPACE}/${cluster}",
cluster: cluster
)
sh("ls ${env.WORKSPACE}/${cluster}/tmp-k8s/")
}
}
}
}
if (env.BRANCH_NAME.equals("main")){
stage("Deploy") {
k8s_contexts = [
"staging",
"datastores-us-central1"
]
// getKubeconfig() is needed to get authentication to the k8s clusters
getKubeconfig()
// withRepoKey is needed in order to decrypt ecfg-encrypted secrets.
// If you don't have secrets, you don't need this. But it wont break
// anything to include it anyway.
withRepoKey {
k8s_contexts.each { cluster ->
template(
basedir: "${env.WORKSPACE}/${cluster}",
cluster: cluster
)
sh("kubectl --context ${cluster} apply -f ${env.WORKSPACE}/${cluster}/tmp-k8s")
}
}
}
}
}