-
Notifications
You must be signed in to change notification settings - Fork 58
/
JenkinsfileSMS.groovy
674 lines (623 loc) · 30.2 KB
/
JenkinsfileSMS.groovy
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
// This Jenkins build requires a configmap called jenkin-config with the following in it:
//
// client_secret=<keycloak client secret>
// zap_with_url_staff=<queue frontend for staff URL>
// zap_with_url=<zap command including dev url for analysis>
// namespace=<openshift project namespace>
// url=<url of api>/api/v1/
// auth_url=<Keycloak domain>
// clientid=<keycload Client ID>
// realm=<keycloak realm>
// dev_namespace=<openshift dev namepaces for testing>
// userid_qtxn=postman tester
// password_qtxn=<cfms-postman-operator password>
// userid_nonqtxn=cfms-postman-non-operator userid>
// password_nonqtxn=<cfms-postman-non-operator password>
// public_user_id=cfms-postman-public-user
// public_user_password=<cfms-postman-public-user password>
// public_url=<public api url>
// sonarqube_key=<sonarqube key>
def WAIT_TIMEOUT = 20
def TAG_NAMES = ['dev', 'test', 'prod']
def BUILDS = ['queue-management-api','queue-management-nginx-frontend','appointment-nginx-frontend','send-appointment-reminder-crond','notifications-api','feedback-api']
def DEP_ENV_NAMES = ['dev', 'test', 'prod']
def label = "mypod-${UUID.randomUUID().toString()}"
def API_IMAGE_HASH = ""
def FRONTEND_IMAGE_HASH = ""
def APPOINTMENT_IMAGE_HASH = ""
def REMINDER_IMAGE_HASH = ""
def NOTIFICATION_IMAGE_HASH = ""
def FEEDBACK_IMAGE_HASH = ""
def owaspPodLabel = "jenkins-agent-zap"
def STAFFURL = ""
def APPTMNTURL = ""
String getNameSpace() {
def NAMESPACE = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^namespace/{print $2}\'',
returnStdout: true
).trim()
return NAMESPACE
}
// Get an image's hash tag
String getImageTagHash(String imageName, String tag = "") {
if(!tag?.trim()) {
tag = "latest"
}
def istag = openshift.raw("get istag ${imageName}:${tag} -o template --template='{{.image.dockerImageReference}}'")
return istag.out.tokenize('@')[1].trim()
}
podTemplate(
label: label,
name: 'jenkins-agent-nodejs',
serviceAccount: 'jenkins',
cloud: 'openshift',
containers: [
containerTemplate(
name: 'jnlp',
image: 'registry.redhat.io/openshift3/jenkins-agent-nodejs-12-rhel7',
resourceRequestCpu: '500m',
resourceLimitCpu: '1000m',
resourceRequestMemory: '3Gi',
resourceLimitMemory: '4Gi',
workingDir: '/tmp',
command: '',
args: '${computer.jnlpmac} ${computer.name}'
)
]
){
node(label) {
stage('Checkout Source') {
echo "checking out source"
checkout scm
}
parallel Build_Staff_FE_NGINX: {
stage("Build Front End NGINX..") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Building Front End Nginx"
openshift.selector("bc", "${BUILDS[1]}").startBuild("--wait")
}
echo "Staff Front End Nginx Completed ..."
}
}
}
}, Build_Appointment_FE_NGINX: {
stage("Build Appointment NGINX") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Bulding Appoitment Front End NPM"
openshift.selector("bc", "${BUILDS[2]}").startBuild("--wait")
}
echo "Appointment NPM ..."
}
}
}
}, Build_Api: {
stage("Build API..") {
script: {
openshift.withCluster() {
openshift.withProject() {
openshift.selector("bc", "${BUILDS[0]}").startBuild("--wait")
}
echo "API Build complete ..."
}
}
}
}, Build_Cron_Pod: {
stage("Build Mail Cron Pod..") {
script: {
openshift.withCluster() {
openshift.withProject() {
openshift.selector("bc", "${BUILDS[3]}").startBuild("--wait")
}
echo "Cron Mail Build complete ..."
}
}
}
}, Build_notifications_api: {
stage("Build notification api") {
script: {
openshift.withCluster() {
openshift.withProject() {
openshift.selector("bc", "${BUILDS[4]}").startBuild("--wait")
}
echo "notification api complete ..."
}
}
}
}, Build_feedback_api: {
stage("Build feedback api") {
script: {
openshift.withCluster() {
openshift.withProject() {
openshift.selector("bc", "${BUILDS[5]}").startBuild("--wait")
}
echo "notification api complete ..."
}
}
}
}
parallel Depoy_API_Dev: {
stage("Deploy API to Dev") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[0]} for deployment to ${TAG_NAMES[0]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
API_IMAGE_HASH = getImageTagHash("${BUILDS[0]}")
echo "API_IMAGE_HASH: ${API_IMAGE_HASH}"
openshift.tag("${BUILDS[0]}@${API_IMAGE_HASH}", "${BUILDS[0]}:${TAG_NAMES[0]}")
}
def NAME_SPACE = getNameSpace()
openshift.withProject("${NAME_SPACE}-${DEP_ENV_NAMES[0]}") {
def dc = openshift.selector('dc', "${BUILDS[0]}")
// Wait for the deployment to complete.
// This will wait until the desired replicas are all available
dc.rollout().status()
}
echo "API Deployment Complete."
}
}
}
}, Depoy_Cron_Dev: {
stage("Deploy Email Cron to Dev") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[3]} for deployment to ${TAG_NAMES[0]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
REMINDER_IMAGE_HASH = getImageTagHash("${BUILDS[3]}")
echo "REMINDER_IMAGE_HASH: ${REMINDER_IMAGE_HASH}"
openshift.tag("${BUILDS[3]}@${REMINDER_IMAGE_HASH}", "${BUILDS[3]}:${TAG_NAMES[0]}")
}
}
}
}
}, Depoy_notifications_api_Dev: {
stage("Deploy notifications api pod") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[4]} for deployment to ${TAG_NAMES[0]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
NOTIFICATION_IMAGE_HASH = getImageTagHash("${BUILDS[4]}")
echo "NOTIFICATION_IMAGE_HASH: ${NOTIFICATION_IMAGE_HASH}"
openshift.tag("${BUILDS[4]}@${NOTIFICATION_IMAGE_HASH}", "${BUILDS[4]}:${TAG_NAMES[0]}")
}
}
}
}
}, Depoy_feedback_api_Dev: {
stage("Deploy feedback api pod") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[5]} for deployment to ${TAG_NAMES[0]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
FEEDBACK_IMAGE_HASH = getImageTagHash("${BUILDS[5]}")
echo "NOTIFICATION_IMAGE_HASH: ${FEEDBACK_IMAGE_HASH}"
openshift.tag("${BUILDS[5]}@${FEEDBACK_IMAGE_HASH}", "${BUILDS[5]}:${TAG_NAMES[0]}")
}
}
}
}
}, Deploy_Staff_FE_NGINX_Dev: {
stage("Deploy Frontend to Dev") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[1]} for deployment to ${TAG_NAMES[0]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
FRONTEND_IMAGE_HASH = getImageTagHash("${BUILDS[1]}")
echo "FRONTEND_IMAGE_HASH: ${FRONTEND_IMAGE_HASH}"
openshift.tag("${BUILDS[1]}@${FRONTEND_IMAGE_HASH}", "${BUILDS[1]}:${TAG_NAMES[0]}")
}
def NAME_SPACE = getNameSpace()
openshift.withProject("${NAME_SPACE}-${DEP_ENV_NAMES[0]}") {
dc = openshift.selector('dc', "${BUILDS[1]}")
// Wait for the deployment to complete.
// This will wait until the desired replicas are all available
dc.rollout().status()
}
echo "Front End Deployment Complete."
}
}
}
}, Deploy_Appointment_NGINX_Dev: {
stage("Deploy Appointment to Dev") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[2]} for deployment to ${TAG_NAMES[0]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
APPOINTMENT_IMAGE_HASH = getImageTagHash("${BUILDS[2]}")
echo "APPOINTMENT_IMAGE_HASH: ${APPOINTMENT_IMAGE_HASH}"
openshift.tag("${BUILDS[2]}@${APPOINTMENT_IMAGE_HASH}", "${BUILDS[2]}:${TAG_NAMES[0]}")
}
def NAME_SPACE = getNameSpace()
openshift.withProject("${NAME_SPACE}-${DEP_ENV_NAMES[0]}") {
dc = openshift.selector('dc', "${BUILDS[2]}")
// Wait for the deployment to complete.
// This will wait until the desired replicas are all available
dc.rollout().status()
}
echo "Appointment Online Complete."
}
}
}
}
stage('Newman Tests') {
dir('api/postman') {
sh (
returnStdout: true,
script: "npm init -y"
)
sh (
returnStdout: true,
script: "npm install newman"
)
USERID = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^userid_qtxn/{print $2}\'',
returnStdout: true
).trim()
PASSWORD = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^password_qtxn/{print $2}\'',
returnStdout: true
).trim()
USERID_NONQTXN = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^userid_nonqtxn/{print $2}\'',
returnStdout: true
).trim()
PASSWORD_NONQTXN = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^password_nonqtxn/{print $2}\'',
returnStdout: true
).trim()
CLIENT_SECRET = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^client_secret/{print $2}\'',
returnStdout: true
).trim()
REALM = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^realm/{print $2}\'',
returnStdout: true
).trim()
API_URL = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^url/{print $2}\'',
returnStdout: true
).trim()
AUTH_URL = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/auth_url/{print $2}\'',
returnStdout: true
).trim()
CLIENTID = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^clientid/{print $2}\'',
returnStdout: true
).trim()
PUBLIC_USERID = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^public_user_id/{print $2}\'',
returnStdout: true
).trim()
PASSWORD_PUBLIC_USER = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^public_user_password/{print $2}\'',
returnStdout: true
).trim()
PUBLIC_API_URL = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^public_url/{print $2}\'',
returnStdout: true
).trim()
NODE_OPTIONS='--max_old_space_size=2048'
sleep(time:10,unit:"SECONDS")
sh (
returnStdout: true,
script: "./node_modules/newman/bin/newman.js run API_Test_TheQ_Booking.json --delay-request 250 -e postman_env.json --global-var 'userid=${USERID}' --global-var 'password=${PASSWORD}' --global-var 'userid_nonqtxn=${USERID_NONQTXN}' --global-var 'password_nonqtxn=${PASSWORD_NONQTXN}' --global-var 'client_secret=${CLIENT_SECRET}' --global-var 'url=${API_URL}' --global-var 'auth_url=${AUTH_URL}' --global-var 'clientid=${CLIENTID}' --global-var 'realm=${REALM}' --global-var public_url=${PUBLIC_API_URL} --global-var public_user_id=${PUBLIC_USERID} --global-var public_user_password=${PASSWORD_PUBLIC_USER}"
)
}
}
}
}
node() {
stage('get url') {
STAFFURL = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^zap_url_staff/{print $2}\'',
returnStdout: true
).trim()
APPTMNTURL = sh (
script: 'oc describe configmap jenkin-config | awk -F "=" \'/^zap_url_appntmnt/{print $2}\'',
returnStdout: true
).trim()
}
}
podTemplate(
label: owaspPodLabel,
name: owaspPodLabel,
serviceAccount: 'jenkins',
cloud: 'openshift',
containers: [ containerTemplate(
name: 'jenkins-agent-zap',
image: 'image-registry.openshift-image-registry.svc:5000/df1ee0-tools/jenkins-agent-zap:latest',
resourceRequestCpu: '1000m',
resourceLimitCpu: '2000m',
resourceRequestMemory: '4Gi',
resourceLimitMemory: '5Gi',
workingDir: '/home/jenkins',
command: '',
args: '${computer.jnlpmac} ${computer.name}'
)]
) {
node(owaspPodLabel) {
stage('ZAP Security Scan') {
def retVal = sh (
returnStatus: true,
script: "/zap/zap-baseline.py -r index2.html -t ${APPTMNTURL}"
)
sh 'echo "<html><head></head><body><a href=index1.html>Staff Front Report</a><br><a href=index2.html>Appointment Front End Report</a></body></html>" > /zap/wrk/index.html'
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: '/zap/wrk',
reportFiles: 'index.html',
reportName: 'OWASPReport',
])
echo "Return value is: ${retVal}"
}
}
}
node {
stage("Deploy to test") {
input "Deploy to test?"
}
}
node {
parallel Depoy_API_Test: {
stage("Deploy API - test") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[0]} for deployment to ${TAG_NAMES[1]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
echo "API_IMAGE_HASH: ${API_IMAGE_HASH}"
openshift.tag("${BUILDS[0]}@${API_IMAGE_HASH}", "${BUILDS[0]}:${TAG_NAMES[1]}")
}
def NAME_SPACE = getNameSpace()
openshift.withProject("${NAME_SPACE}-${DEP_ENV_NAMES[1]}") {
def dc = openshift.selector('dc', "${BUILDS[0]}")
// Wait for the deployment to complete.
// This will wait until the desired replicas are all available
dc.rollout().status()
}
echo "API Deployment Complete."
}
}
}
}, Deploy_Staff_FE_NGINX_Test: {
stage("Deploy Frontend - Test") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[1]} for deployment to ${TAG_NAMES[1]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
echo "FRONTEND_IMAGE_HASH: ${FRONTEND_IMAGE_HASH}"
openshift.tag("${BUILDS[1]}@${FRONTEND_IMAGE_HASH}", "${BUILDS[1]}:${TAG_NAMES[1]}")
}
def NAME_SPACE = getNameSpace()
openshift.withProject("${NAME_SPACE}-${DEP_ENV_NAMES[1]}") {
dc = openshift.selector('dc', "${BUILDS[1]}")
// Wait for the deployment to complete.
// This will wait until the desired replicas are all available
dc.rollout().status()
}
echo "Front End Deployment Complete."
}
}
}
}, Deploy_Appointment_NGINX_Test: {
stage("Deploy Appointment - Test") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[2]} for deployment to ${TAG_NAMES[1]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
echo "APPOINTMENT_IMAGE_HASH: ${APPOINTMENT_IMAGE_HASH}"
openshift.tag("${BUILDS[2]}@${APPOINTMENT_IMAGE_HASH}", "${BUILDS[2]}:${TAG_NAMES[1]}")
}
def NAME_SPACE = getNameSpace()
openshift.withProject("${NAME_SPACE}-${DEP_ENV_NAMES[1]}") {
dc = openshift.selector('dc', "${BUILDS[2]}")
// Wait for the deployment to complete.
// This will wait until the desired replicas are all available
dc.rollout().status()
}
echo "Front End Deployment Complete."
}
}
}
}, Depoy_notifications_api_Test: {
stage("Deploy notifications api pod") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[4]} for deployment to ${TAG_NAMES[1]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
echo "NOTIFICATION_IMAGE_HASH: ${NOTIFICATION_IMAGE_HASH}"
openshift.tag("${BUILDS[4]}@${NOTIFICATION_IMAGE_HASH}", "${BUILDS[4]}:${TAG_NAMES[1]}")
}
}
}
}
}, Depoy_feedback_api_Test: {
stage("Deploy feedback api pod") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[5]} for deployment to ${TAG_NAMES[1]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
echo "NOTIFICATION_IMAGE_HASH: ${FEEDBACK_IMAGE_HASH}"
openshift.tag("${BUILDS[5]}@${FEEDBACK_IMAGE_HASH}", "${BUILDS[5]}:${TAG_NAMES[1]}")
}
}
}
}
}, Deploy_Cron_Email_Test: {
stage("Deploy Appt Reminder - test") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[3]} for deployment to ${TAG_NAMES[1]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
echo "REMINDER_IMAGE_HASH: ${REMINDER_IMAGE_HASH}"
openshift.tag("${BUILDS[3]}@${REMINDER_IMAGE_HASH}", "${BUILDS[3]}:${TAG_NAMES[1]}")
}
echo "Appt Reminder Deployment Complete."
}
}
}
}
}
node {
stage("Deploy to prod") {
input "Deploy to Prod?"
}
}
node {
stage("Update Production") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging Production to Stable"
openshift.tag("${BUILDS[0]}:prod", "${BUILDS[0]}:stable")
openshift.tag("${BUILDS[1]}:prod", "${BUILDS[1]}:stable")
openshift.tag("${BUILDS[2]}:prod", "${BUILDS[2]}:stable")
openshift.tag("${BUILDS[3]}:prod", "${BUILDS[3]}:stable")
openshift.tag("${BUILDS[4]}:prod", "${BUILDS[4]}:stable")
openshift.tag("${BUILDS[5]}:prod", "${BUILDS[5]}:stable")
}
}
}
}
}
node {
parallel Depoy_API_Prod: {
stage("Deploy API - Prod") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[0]} for deployment to ${TAG_NAMES[2]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
echo "API_IMAGE_HASH: ${API_IMAGE_HASH}"
openshift.tag("${BUILDS[0]}@${API_IMAGE_HASH}", "${BUILDS[0]}:${TAG_NAMES[2]}")
}
def NAME_SPACE = getNameSpace()
openshift.withProject("${NAME_SPACE}-${DEP_ENV_NAMES[2]}") {
def dc = openshift.selector('dc', "${BUILDS[0]}")
// Wait for the deployment to complete.
// This will wait until the desired replicas are all available
dc.rollout().status()
}
echo "API Deployment Complete."
}
}
}
}, Deploy_Staff_FE_NGINX_Prod: {
stage("Deploy Frontend - Prod") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[1]} for deployment to ${TAG_NAMES[2]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
echo "FRONTEND_IMAGE_HASH: ${FRONTEND_IMAGE_HASH}"
openshift.tag("${BUILDS[1]}@${FRONTEND_IMAGE_HASH}", "${BUILDS[1]}:${TAG_NAMES[2]}")
}
def NAME_SPACE = getNameSpace()
openshift.withProject("${NAME_SPACE}-${DEP_ENV_NAMES[2]}") {
dc = openshift.selector('dc', "${BUILDS[1]}")
// Wait for the deployment to complete.
// This will wait until the desired replicas are all available
dc.rollout().status()
}
echo "Front End Deployment Complete."
}
}
}
}, Deploy_Appointment_NGINX_Prod: {
stage("Deploy Appointment - Prod") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[2]} for deployment to ${TAG_NAMES[2]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
echo "APPOINTMENT_IMAGE_HASH: ${APPOINTMENT_IMAGE_HASH}"
openshift.tag("${BUILDS[2]}@${APPOINTMENT_IMAGE_HASH}", "${BUILDS[2]}:${TAG_NAMES[2]}")
}
def NAME_SPACE = getNameSpace()
openshift.withProject("${NAME_SPACE}-${DEP_ENV_NAMES[2]}") {
dc = openshift.selector('dc', "${BUILDS[2]}")
// Wait for the deployment to complete.
// This will wait until the desired replicas are all available
dc.rollout().status()
}
echo "Front End Deployment Complete."
}
}
}
}, Depoy_notifications_api_Prod: {
stage("Deploy notifications api pod - PROD") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[4]} for deployment to ${TAG_NAMES[2]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
echo "NOTIFICATION_IMAGE_HASH: ${NOTIFICATION_IMAGE_HASH}"
openshift.tag("${BUILDS[4]}@${NOTIFICATION_IMAGE_HASH}", "${BUILDS[4]}:${TAG_NAMES[2]}")
}
}
}
}
}, Depoy_feedback_api_Prod: {
stage("Deploy feedback api pod - PROD") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[5]} for deployment to ${TAG_NAMES[2]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
echo "NOTIFICATION_IMAGE_HASH: ${FEEDBACK_IMAGE_HASH}"
openshift.tag("${BUILDS[5]}@${FEEDBACK_IMAGE_HASH}", "${BUILDS[5]}:${TAG_NAMES[2]}")
}
}
}
}
}, Deploy_Cron_Email_Prod: {
stage("Deploy Appt Reminders - Prod") {
script: {
openshift.withCluster() {
openshift.withProject() {
echo "Tagging ${BUILDS[3]} for deployment to ${TAG_NAMES[2]} ..."
// Don't tag with BUILD_ID so the pruner can do it's job; it won't delete tagged images.
// Tag the images for deployment based on the image's hash
echo "REMINDER_IMAGE_HASH: ${REMINDER_IMAGE_HASH}"
openshift.tag("${BUILDS[3]}@${REMINDER_IMAGE_HASH}", "${BUILDS[3]}:${TAG_NAMES[2]}")
}
echo "Appt Reminders Deployment Complete."
}
}
}
}
}