I have a series of stages that perform quick checks. I want to perform them all, even if there are failures. For example:
stage(\'one\') {
node {
It depends whether you are using declarative pipeline syntax or scripted pipeline syntax.
declarative pipeline syntax:
pipeline {
agent any
stages {
stage('one') {
steps {
sh 'exit 0'
}
}
stage('two') {
steps {
sh 'exit 1' // failure
}
}
}
post {
always {
sh 'exit 0'
}
}
}
Post-condition blocks contain steps the same as the steps section.
scripted pipeline syntax:
node {
def build_ok = true
stage('one') {
sh 'exit 0'
}
try{
stage('two') {
sh 'exit 1' // failure
}
} catch(e) {
build_ok = false
echo e.toString()
}
stage('three') {
sh 'exit 0'
}
if(build_ok) {
currentBuild.result = "SUCCESS"
} else {
currentBuild.result = "FAILURE"
}
}