-
Notifications
You must be signed in to change notification settings - Fork 14
/
Jenkinsfile
74 lines (72 loc) · 2.8 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
pipeline {
agent none
options {
disableResume()
}
stages {
stage('Build') {
agent { label 'build' }
steps {
script {
openshift.withCluster() {
def filesInThisCommitAsString = sh(script:"git diff --name-only HEAD~1..HEAD | grep '^' || echo -n ''", returnStatus: false, returnStdout: true).trim()
def hasChangesInPath = (filesInThisCommitAsString.length() > 0)
echo "Files Changed ..."
echo "${filesInThisCommitAsString}"
if (!currentBuild.rawBuild.getCauses()[0].toString().contains('UserIdCause') && !hasChangesInPath){
currentBuild.rawBuild.delete()
error("No changes detected in the path ('^')")
}
// Need to check eachline for either angular/ or api/
def angular = false;
def api = false;
// 2 years and it's still not fixed :s
// https://issues.jenkins-ci.org/browse/JENKINS-46988
filesInThisCommitAsString.split('\n').each {
if (it =~ /angular/) {
angular = true;
}
if (it =~ /api/) {
api = true;
}
}
echo "Angular: ${angular}, API: ${api}"
if (angular) {
// Fire up the angular builder
echo "Running Angular builder"
def angularSelector = openshift.selector("bc", "angular-app-build").startBuild()
angularSelector.untilEach(1) {
return it.object().status.phase == "Complete"
}
echo "Deploying to NRCED Admin"
def nrcedSelector = openshift.selector("bc", "admin-nrced-build").startBuild()
nrcedSelector.untilEach(1) {
return it.object().status.phase == "Complete"
}
echo "Deploying to NRCED Public"
def publicNRPTI = openshift.selector("bc", "public-nrced-build").startBuild()
publicNRPTI.untilEach(1) {
return it.object().status.phase == "Complete"
}
echo "Deploying to PUBLIC LNG"
def lngSelector = openshift.selector("bc", "public-lng-build").startBuild()
lngSelector.untilEach(1) {
return it.object().status.phase == "Complete"
}
echo "Front end builds complete and deployed to Dev"
}
if (api) {
// Fire up the api builder
echo "Running API builder"
def apiSelector = openshift.selector("bc", "nrpti-api").startBuild()
apiSelector.untilEach(1) {
return it.object().status.phase == "Complete"
}
echo "Deploying to Dev"
}
}
}
}
}
}
}