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}-*"
|
archiveArtifacts artifacts: "${env.JOB_BASE_NAME}-*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def anySuccess = false
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
|
||||||
@@ -69,6 +71,10 @@ pipeline {
|
|||||||
windowsBuild()
|
windowsBuild()
|
||||||
saveArtifacts()
|
saveArtifacts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
script {
|
||||||
|
anySuccess = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,20 +87,23 @@ pipeline {
|
|||||||
unixBuild()
|
unixBuild()
|
||||||
saveArtifacts()
|
saveArtifacts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
script {
|
||||||
|
anySuccess = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we're on the main jobs, trigger each of the downstream jobs. */
|
/* This stage has two tasks:
|
||||||
stage('Trigger downstream jobs') {
|
- Fail the build if all build stages failed
|
||||||
when {
|
- Trigger downstream jobs if we're on the main job
|
||||||
expression {
|
This could be done with two stages and when{} blocks, but then they
|
||||||
return env.JOB_BASE_NAME == '86Box-TestBuildPleaseIgnore';
|
would show up separately in the UI (unless JENKINS-44094 happens). */
|
||||||
}
|
stage('Finish build') {
|
||||||
}
|
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
|
if (env.JOB_BASE_NAME == '86Box-TestBuildPleaseIgnore') {
|
||||||
["${env.JOB_BASE_NAME}2"].each {
|
["${env.JOB_BASE_NAME}2"].each {
|
||||||
try {
|
try {
|
||||||
/* Set next build number for this job. */
|
/* 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