@@ -22,32 +22,6 @@ def RELEASE_ON_SCHEDULE = true // Set to `true` *only* on branches where you wan
22
22
print " INFO: env.PROJECT = ${ env.PROJECT} "
23
23
print " INFO: env.JIRA_KEY = ${ env.JIRA_KEY} "
24
24
25
- // --------------------------------------------
26
- // Build conditions
27
-
28
- // Avoid running the pipeline on branch indexing
29
- if (currentBuild. getBuildCauses(). toString(). contains(' BranchIndexingCause' )) {
30
- print " INFO: Build skipped due to trigger being Branch Indexing"
31
- currentBuild. result = ' NOT_BUILT'
32
- return
33
- }
34
-
35
- def manualRelease = currentBuild. getBuildCauses(). toString(). contains( ' UserIdCause' )
36
- def cronRelease = currentBuild. getBuildCauses(). toString(). contains( ' TimerTriggerCause' )
37
-
38
- // Only do automatic release on branches where we opted in
39
- if ( ! manualRelease && ! cronRelease ) {
40
- print " INFO: Build skipped because automated releases on push are disabled on this branch."
41
- currentBuild. result = ' NOT_BUILT'
42
- return
43
- }
44
-
45
- if ( ! manualRelease && cronRelease && ! RELEASE_ON_SCHEDULE ) {
46
- print " INFO: Build skipped because automated releases are disabled on this branch. See constant RELEASE_ON_SCHEDULE in ci/release/Jenkinsfile"
47
- currentBuild. result = ' NOT_BUILT'
48
- return
49
- }
50
-
51
25
// --------------------------------------------
52
26
// Reusable methods
53
27
@@ -62,6 +36,9 @@ def checkoutReleaseScripts() {
62
36
// --------------------------------------------
63
37
// Pipeline
64
38
39
+ // NOTE: this job checks pre-conditions
40
+ // and may cancel itself before even running,
41
+ // see "Build conditions" at the bottom of this file.
65
42
pipeline {
66
43
agent {
67
44
label ' Release'
@@ -275,3 +252,33 @@ pipeline {
275
252
}
276
253
}
277
254
}
255
+
256
+ // --------------------------------------------
257
+ // Build conditions
258
+
259
+ // Note this code is at the end of the file for a reason:
260
+ // this code gets executed after Jenkins parses the Jenkinsfile (so that Jenkins knows about the build's parameters/options)
261
+ // but before Jenkins runs the build (so that we can cancel it before an agent is even started).
262
+
263
+ // Avoid running the pipeline on branch indexing
264
+ if (currentBuild. getBuildCauses(). toString(). contains(' BranchIndexingCause' )) {
265
+ print " INFO: Build skipped due to trigger being Branch Indexing"
266
+ currentBuild. result = ' NOT_BUILT'
267
+ return
268
+ }
269
+
270
+ def manualRelease = currentBuild. getBuildCauses(). toString(). contains( ' UserIdCause' )
271
+ def cronRelease = currentBuild. getBuildCauses(). toString(). contains( ' TimerTriggerCause' )
272
+
273
+ // Only do automatic release on branches where we opted in
274
+ if ( ! manualRelease && ! cronRelease ) {
275
+ print " INFO: Build skipped because automated releases on push are disabled on this branch."
276
+ currentBuild. result = ' NOT_BUILT'
277
+ return
278
+ }
279
+
280
+ if ( ! manualRelease && cronRelease && ! RELEASE_ON_SCHEDULE ) {
281
+ print " INFO: Build skipped because automated releases are disabled on this branch. See constant RELEASE_ON_SCHEDULE in ci/release/Jenkinsfile"
282
+ currentBuild. result = ' NOT_BUILT'
283
+ return
284
+ }
0 commit comments