@@ -22,6 +22,32 @@ 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
+
25
51
// --------------------------------------------
26
52
// Reusable methods
27
53
@@ -36,9 +62,6 @@ def checkoutReleaseScripts() {
36
62
// --------------------------------------------
37
63
// Pipeline
38
64
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.
42
65
pipeline {
43
66
agent {
44
67
label ' Release'
@@ -252,33 +275,3 @@ pipeline {
252
275
}
253
276
}
254
277
}
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