diff --git a/ci/release/Jenkinsfile b/ci/release/Jenkinsfile index f1f43818b395..ac17cd7df685 100644 --- a/ci/release/Jenkinsfile +++ b/ci/release/Jenkinsfile @@ -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 @@ -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' @@ -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 -}