-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
78 lines (71 loc) · 2.33 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
@Library('devops-library') _
// Edit your app's name below
def APP_NAME = 'frontend'
def FRONTEND_B = 'frontend-blue'
def FRONTEND_G = 'frontend-green'
def API_B = 'api-blue'
def API_G = 'api-green'
def PATHFINDER_URL = "pathfinder.gov.bc.ca"
def PROJECT_PREFIX = "jag-shuber"
// Edit your environment TAG names below
def TAG_NAMES = [
'prod'
]
def APP_URLS = [
"https://${APP_NAME}-${PROJECT_PREFIX}-${TAG_NAMES[0]}.${PATHFINDER_URL}"
]
def SLACK_PROD_CHANNEL="sheriff_prod_approval"
def SLACK_MAIN_CHANNEL="#sheriff_scheduling"
stage('Approval notification'){
node{
// Check for current route target
ROUT_CHK = sh (
script: """oc project jag-shuber-test; oc get route frontend -o template --template='{{ .spec.to.name }}' > route-target; cat route-target""")
// echo ">> ROUT_CHK: ${ROUT_CHK}"
slackNotify(
"To Deploy Blue stack with prod tagged image 🚀",
"To switch to new version",
'Please Aproove or Deny!!',
env.PROD_SLACK_HOOK,
SLACK_PROD_CHANNEL,
[
[
type: "button",
text: "Approve",
url: "${currentBuild.absoluteUrl}/input"
],
[
type: "button",
text: "Deny",
style: "primary",
url: "${currentBuild.absoluteUrl}/input"
]
])
}
}
// Deploying to production
stage('Deploy to prod'){
timeout(time:3, unit: 'DAYS'){ input id: 'TestProd', message: "Deploy to prod ${PROJECT_PREFIX}", submitter: 'kusingh6-admin', submitterParameter: 'approvingSubmitter' }
node{
// Checking current targeted route
echo "Hello! This is just a test"
echo "${currentTarget} & ${newTarget}"
}
}
// // Functions to check currentTarget (api-blue)deployment and mark to for deployment to newTarget(api-green) & vice versa
def getCurrentTarget() {
def currentTarget = readFile("route-target")
return currentTarget
}
def getNewTarget() {
def currentTarget = getCurrentTarget()
def newTarget = ""
if (currentTarget == 'frontend') {
newTarget = 'api-green'
} else if (currentTarget == 'api-green') {
newTarget = 'api-blue'
} else {
echo "OOPS, wrong target"
}
return newTarget
}