This repository has been archived by the owner on Mar 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Jenkinsfile
95 lines (95 loc) · 3.47 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
pipeline {
agent none
environment {
COMPONENT_NAME = 'BCGov SSO KeyCloak app'
}
options {
disableResume()
}
stages {
stage('Build') {
agent { label 'build' }
steps {
script {
// only continue build if changes are relevant to the BCGov SSO KeyCloak app
// TODO: restructure OCP folders
def filesInThisCommitAsString = sh(script:"git diff --name-only HEAD~1..HEAD | grep -e '^docker/' -e '^extensions/' -e '^openshift/sso*' -e '^.pipeline/' || echo -n ''", returnStatus: false, returnStdout: true).trim()
def hasChangesInPath = (filesInThisCommitAsString.length() > 0)
echo "Changes including:"
echo "${filesInThisCommitAsString}"
if (!currentBuild.rawBuild.getCauses()[0].toString().contains('UserIdCause') && !hasChangesInPath){
currentBuild.rawBuild.delete()
error("No changes detected in the component path for $COMPONENT_NAME")
}
}
echo "Aborting all running jobs for $COMPONENT_NAME"
script {
abortAllPreviousBuildInProgress(currentBuild)
}
echo "Building ..."
sh "cd .pipeline && ./npmw ci && ./npmw run build -- --pr=${CHANGE_ID}"
}
}
stage('Deploy (SANDBOX)') {
agent { label 'deploy' }
steps {
echo "Deploying ..."
sh "cd .pipeline && ./npmw ci && ./npmw run deploy -- --pr=${CHANGE_ID} --env=sbox"
}
}
stage('Deploy (DEV)') {
agent { label 'deploy' }
when {
expression {
return env.CHANGE_TARGET == 'master';
}
beforeInput true;
}
input {
message "Should we continue with deployment to DEV?"
ok "Yes!"
submitter "authenticated"
}
steps {
echo "Deploying ..."
sh "cd .pipeline && ./npmw ci && ./npmw run deploy -- --pr=${CHANGE_ID} --env=dev"
}
}
stage('Deploy (TEST)') {
agent { label 'deploy' }
when {
expression {
return env.CHANGE_TARGET == 'master';
}
beforeInput true;
}
input {
message "Should we continue with deployment to TEST?"
ok "Yes!"
submitter "authenticated"
}
steps {
echo "Deploying ..."
sh "cd .pipeline && ./npmw ci && ./npmw run deploy -- --pr=${CHANGE_ID} --env=test"
}
}
stage('Deploy (PROD)') {
agent { label 'deploy' }
when {
expression {
return env.CHANGE_TARGET == 'master';
}
beforeInput true;
}
input {
message "Should we continue with deployment to PROD? Have you notified the community?"
ok "Yes!"
submitter "authenticated"
}
steps {
echo "Deploying ..."
sh "cd .pipeline && ./npmw ci && ./npmw run deploy -- --pr=${CHANGE_ID} --env=prod"
}
}
}
}