Move Jenkins post-build tasks to a post{} block
This commit is contained in:
59
.ci/Jenkinsfile
vendored
59
.ci/Jenkinsfile
vendored
@@ -51,7 +51,7 @@ def saveArtifacts() {
|
||||
def anySuccess = false
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
agent none
|
||||
|
||||
parameters {
|
||||
string(name: 'BUILD_TYPE',
|
||||
@@ -94,42 +94,37 @@ pipeline {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* This stage has two tasks:
|
||||
- Trigger downstream jobs if we're on the main job
|
||||
- Fail this build if all build stages failed
|
||||
This could be done with two stages and when{} blocks, but then they
|
||||
would show up separately in the UI (unless JENKINS-44094 happens). */
|
||||
stage('Finish build') {
|
||||
steps {
|
||||
script {
|
||||
if (env.JOB_BASE_NAME == '86Box-TestBuildPleaseIgnore') {
|
||||
["${env.JOB_BASE_NAME}2"].each {
|
||||
try {
|
||||
/* Set next build number for this job. */
|
||||
def job = Jenkins.instance.getItem(it)
|
||||
job.nextBuildNumber = env.BUILD_NUMBER as Integer
|
||||
job.saveNextBuildNumber()
|
||||
} catch (Exception e) {
|
||||
println "[!] Could not set next build number for [$it], make sure all the script approvals are in place"
|
||||
}
|
||||
|
||||
/* Trigger this job. */
|
||||
build propagate: false,
|
||||
wait: false,
|
||||
job: it,
|
||||
parameters: [
|
||||
string(name: 'BUILD_TYPE', value: BUILD_TYPE),
|
||||
string(name: 'BRANCH', value: env.GIT_COMMIT)
|
||||
]
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
if (env.JOB_BASE_NAME == '86Box-TestBuildPleaseIgnore') {
|
||||
["${env.JOB_BASE_NAME}2"].each {
|
||||
try {
|
||||
/* Set next build number for this job. */
|
||||
def job = Jenkins.instance.getItem(it)
|
||||
job.nextBuildNumber = env.BUILD_NUMBER as Integer
|
||||
job.saveNextBuildNumber()
|
||||
} catch (Exception e) {
|
||||
println "[!] Could not set next build number for [$it], make sure all the script approvals are in place"
|
||||
}
|
||||
}
|
||||
|
||||
if (!anySuccess) {
|
||||
println "[!] Failing build because all build stages failed"
|
||||
currentBuild.result = 'FAILURE'
|
||||
/* Trigger this job. */
|
||||
build propagate: false,
|
||||
wait: false,
|
||||
job: it,
|
||||
parameters: [
|
||||
string(name: 'BUILD_TYPE', value: BUILD_TYPE),
|
||||
string(name: 'BRANCH', value: env.GIT_COMMIT)
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (!anySuccess) {
|
||||
println "[!] Failing build because all build stages failed"
|
||||
currentBuild.result = 'FAILURE'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user