Add failure mode to Jenkins pipeline
This commit is contained in:
31
.ci/Jenkinsfile
vendored
31
.ci/Jenkinsfile
vendored
@@ -48,6 +48,8 @@ def saveArtifacts() {
|
||||
archiveArtifacts artifacts: "${env.JOB_BASE_NAME}-*"
|
||||
}
|
||||
|
||||
def anySuccess = false
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
@@ -69,6 +71,10 @@ pipeline {
|
||||
windowsBuild()
|
||||
saveArtifacts()
|
||||
}
|
||||
|
||||
script {
|
||||
anySuccess = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,20 +87,23 @@ pipeline {
|
||||
unixBuild()
|
||||
saveArtifacts()
|
||||
}
|
||||
|
||||
script {
|
||||
anySuccess = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If we're on the main jobs, trigger each of the downstream jobs. */
|
||||
stage('Trigger downstream jobs') {
|
||||
when {
|
||||
expression {
|
||||
return env.JOB_BASE_NAME == '86Box-TestBuildPleaseIgnore';
|
||||
}
|
||||
}
|
||||
|
||||
/* This stage has two tasks:
|
||||
- Fail the build if all build stages failed
|
||||
- Trigger downstream jobs if we're on the main job
|
||||
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. */
|
||||
@@ -115,6 +124,12 @@ pipeline {
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (!anySuccess) {
|
||||
println "[!] Failing build because all build stages failed"
|
||||
currentBuild.result = 'FAILURE'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user