Skip to content

Commit b0746b8

Browse files
committed
Revert "Allow Jenkins to parse the release Jenkinsfile before cancelling non-release triggers"
This reverts commit ffecd7d. This reverts PR #9617 See #9571 (comment)
1 parent ffecd7d commit b0746b8

File tree

1 file changed

+26
-33
lines changed

1 file changed

+26
-33
lines changed

ci/release/Jenkinsfile

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,32 @@ def RELEASE_ON_SCHEDULE = true // Set to `true` *only* on branches where you wan
2222
print "INFO: env.PROJECT = ${env.PROJECT}"
2323
print "INFO: env.JIRA_KEY = ${env.JIRA_KEY}"
2424

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+
2551
// --------------------------------------------
2652
// Reusable methods
2753

@@ -36,9 +62,6 @@ def checkoutReleaseScripts() {
3662
// --------------------------------------------
3763
// Pipeline
3864

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.
4265
pipeline {
4366
agent {
4467
label 'Release'
@@ -252,33 +275,3 @@ pipeline {
252275
}
253276
}
254277
}
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

Comments
 (0)