Skip to content

Commit

Permalink
Revert "Allow Jenkins to parse the release Jenkinsfile before cancell…
Browse files Browse the repository at this point in the history
…ing non-release triggers"

This reverts commit ffecd7d.

This reverts PR #9617

See #9571 (comment)
  • Loading branch information
yrodiere committed Jan 15, 2025
1 parent ffecd7d commit b0746b8
Showing 1 changed file with 26 additions and 33 deletions.
59 changes: 26 additions & 33 deletions ci/release/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,32 @@ def RELEASE_ON_SCHEDULE = true // Set to `true` *only* on branches where you wan
print "INFO: env.PROJECT = ${env.PROJECT}"
print "INFO: env.JIRA_KEY = ${env.JIRA_KEY}"

// --------------------------------------------
// Build conditions

// Avoid running the pipeline on branch indexing
if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) {
print "INFO: Build skipped due to trigger being Branch Indexing"
currentBuild.result = 'NOT_BUILT'
return
}

def manualRelease = currentBuild.getBuildCauses().toString().contains( 'UserIdCause' )
def cronRelease = currentBuild.getBuildCauses().toString().contains( 'TimerTriggerCause' )

// Only do automatic release on branches where we opted in
if ( !manualRelease && !cronRelease ) {
print "INFO: Build skipped because automated releases on push are disabled on this branch."
currentBuild.result = 'NOT_BUILT'
return
}

if ( !manualRelease && cronRelease && !RELEASE_ON_SCHEDULE ) {
print "INFO: Build skipped because automated releases are disabled on this branch. See constant RELEASE_ON_SCHEDULE in ci/release/Jenkinsfile"
currentBuild.result = 'NOT_BUILT'
return
}

// --------------------------------------------
// Reusable methods

Expand All @@ -36,9 +62,6 @@ def checkoutReleaseScripts() {
// --------------------------------------------
// Pipeline

// NOTE: this job checks pre-conditions
// and may cancel itself before even running,
// see "Build conditions" at the bottom of this file.
pipeline {
agent {
label 'Release'
Expand Down Expand Up @@ -252,33 +275,3 @@ pipeline {
}
}
}

// --------------------------------------------
// Build conditions

// Note this code is at the end of the file for a reason:
// this code gets executed after Jenkins parses the Jenkinsfile (so that Jenkins knows about the build's parameters/options)
// but before Jenkins runs the build (so that we can cancel it before an agent is even started).

// Avoid running the pipeline on branch indexing
if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) {
print "INFO: Build skipped due to trigger being Branch Indexing"
currentBuild.result = 'NOT_BUILT'
return
}

def manualRelease = currentBuild.getBuildCauses().toString().contains( 'UserIdCause' )
def cronRelease = currentBuild.getBuildCauses().toString().contains( 'TimerTriggerCause' )

// Only do automatic release on branches where we opted in
if ( !manualRelease && !cronRelease ) {
print "INFO: Build skipped because automated releases on push are disabled on this branch."
currentBuild.result = 'NOT_BUILT'
return
}

if ( !manualRelease && cronRelease && !RELEASE_ON_SCHEDULE ) {
print "INFO: Build skipped because automated releases are disabled on this branch. See constant RELEASE_ON_SCHEDULE in ci/release/Jenkinsfile"
currentBuild.result = 'NOT_BUILT'
return
}

0 comments on commit b0746b8

Please sign in to comment.