-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJenkinsfile
More file actions
45 lines (37 loc) · 1.42 KB
/
Jenkinsfile
File metadata and controls
45 lines (37 loc) · 1.42 KB
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
node {
def project = 'snsumner75'
def appName = 'python_api'
def feSvcName = "${appName}"
def namespace = 'production'
def imageTag = "quay.io/${project}/${appName}:${env.BRANCH_NAME}.v${env.BUILD_NUMBER}"
checkout scm
stage 'Printenv'
sh("printenv")
stage 'Login to Quay.io'
sh("docker login -u=\"${env.quay_username}\" -p=\"${env.quay_password}\" quay.io")
stage 'Build image'
sh("docker build -t ${imageTag} .")
// stage 'Run Go tests '
// sh("docker run ${imageTag} go test")
stage 'Push image to Quay.io registry'
sh("docker push ${imageTag}")
stage "Deploy Application"
switch (env.BRANCH_NAME) {
case "canary":
// Roll out to canary environment
// Change deployed image in canary to the one we just built
sh("sed -i.bak 's#quay.io/${project}/${appName}:.*\$#${imageTag}#' ./k8s/canary/*.yaml")
sh("kubectl --namespace=${namespace} apply -f k8s/services/")
sh("kubectl --namespace=${namespace} apply -f k8s/canary/")
break
case "production":
// Roll out to production environment
// Change deployed image in canary to the one we just built
sh("sed -i.bak 's#quay.io/${project}/${appName}:.*\$#${imageTag}#' ./k8s/production/*.yaml")
sh("kubectl --namespace=${namespace} apply -f k8s/services/")
sh("kubectl --namespace=${namespace} apply -f k8s/production/")
break
default:
break
}
}