@@ -69,11 +69,11 @@ def UNIT_RESULTS = "${TEST_RESULTS_FOLDER}/unit"
69
69
*/
70
70
def MASTER_BRANCH = " master"
71
71
72
-
73
72
/**
74
- * A command to be run that gets the current revision pulled down
73
+ * Variables to check any new commit since the previous successful commit
75
74
*/
76
- def GIT_REVISION_LOOKUP = ' git log -n 1 --pretty=format:%h'
75
+ def GIT_COMMIT = " null"
76
+ def GIT_PREVIOUS_SUCCESSFUL_COMMIT = " null"
77
77
78
78
/**
79
79
* This is the product name used by the build machine to store information about
@@ -130,8 +130,13 @@ pipeline {
130
130
stage(" Clean workspace and checkout source" ) {
131
131
steps {
132
132
timeout(time : 5 , unit : ' MINUTES' ) {
133
- cleanWs()
134
- checkout scm
133
+ script {
134
+ cleanWs()
135
+ scmInfo = checkout scm
136
+
137
+ GIT_COMMIT = scmInfo. GIT_COMMIT
138
+ GIT_PREVIOUS_SUCCESSFUL_COMMIT = scmInfo. GIT_PREVIOUS_SUCCESSFUL_COMMIT
139
+ }
135
140
}
136
141
}
137
142
}
@@ -164,12 +169,6 @@ pipeline {
164
169
steps {
165
170
timeout(time : 2 , unit : ' MINUTES' ) {
166
171
script {
167
- // We need to keep track of the current commit revision. This is to prevent the condition where
168
- // the build starts on master and another branch gets merged to master prior to version bump
169
- // commit taking place. If left unhandled, the version bump could be done on latest master branch
170
- // code which would already be ahead of this build.
171
- BUILD_REVISION = sh returnStdout : true , script : GIT_REVISION_LOOKUP
172
-
173
172
// This checks for the [ci skip] text. If found, the status code is 0
174
173
def result = sh returnStatus : true , script : ' git log -1 | grep \' .*\\ [ci skip\\ ].*\' '
175
174
if (result == 0 ) {
@@ -542,6 +541,9 @@ pipeline {
542
541
expression {
543
542
return BRANCH_NAME == MASTER_BRANCH
544
543
}
544
+ expression {
545
+ return GIT_COMMIT != GIT_PREVIOUS_SUCCESSFUL_COMMIT
546
+ }
545
547
}
546
548
}
547
549
steps {
@@ -591,7 +593,10 @@ pipeline {
591
593
return PIPELINE_CONTROL . deploy
592
594
}
593
595
expression {
594
- return BRANCH_NAME == MASTER_BRANCH
596
+ return BRANCH_NAME == MASTER_BRANCH
597
+ }
598
+ expression {
599
+ return GIT_COMMIT != GIT_PREVIOUS_SUCCESSFUL_COMMIT
595
600
}
596
601
}
597
602
}
@@ -622,7 +627,6 @@ pipeline {
622
627
}
623
628
}
624
629
}
625
-
626
630
}
627
631
post {
628
632
unsuccessful {
0 commit comments