forked from bcgov/RSBC-DataHub-API
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
80 lines (80 loc) · 2.87 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
pipeline {
agent none
options {
disableResume()
}
stages {
stage('Build') {
agent { label 'build' }
steps {
script {
def filesInThisCommitAsString = sh(script:"git diff --name-only HEAD~1..HEAD | grep -v '^.jenkins/' || echo -n ''", returnStatus: false, returnStdout: true).trim()
def hasChangesInPath = (filesInThisCommitAsString.length() > 0)
echo "${filesInThisCommitAsString}"
if (!currentBuild.rawBuild.getCauses()[0].toString().contains('UserIdCause') && !hasChangesInPath){
currentBuild.rawBuild.delete()
error("No changes detected in the path ('^.jenkins/')")
}
}
echo "Aborting all running jobs ..."
script {
abortAllPreviousBuildInProgress(currentBuild)
}
echo "Building ..."
sh "cd .pipeline && ./npmw ci && ./npmw run build -- --pr=${CHANGE_ID}"
}
}
stage('Deploy (PR)') {
agent { label 'deploy' }
steps {
echo "Deploying PR ..."
sh "cd .pipeline && ./npmw ci && DEBUG=* ./npmw run deploy -- --pr=${CHANGE_ID} --env=pr"
}
}
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!"
}
steps {
echo "Deploying to DEV..."
sh "cd .pipeline && ./npmw ci && DEBUG=* ./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!"
}
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?"
ok "Yes!"
}
steps {
echo "Deploying ..."
sh "cd .pipeline && ./npmw ci && ./npmw run deploy -- --pr=${CHANGE_ID} --env=prod"
}
}
}
}