forked from bcgov/tfrs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
65 lines (65 loc) · 2.35 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
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 (DEV)') {
agent { label 'deploy' }
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!"
}
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 TEST?"
ok "Yes!"
}
steps {
echo "Deploying ..."
sh "cd .pipeline && ./npmw ci && ./npmw run deploy -- --pr=${CHANGE_ID} --env=prod"
}
}
}
}