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 {
sh 'exit 0'
}
}
stage('two') {
node {
sh 'exit 1' // failure
}
}
stage('three') {
node {
sh 'exit 0'
}
}
Stage two
fails, so by default stage three
is not executed.
Ordinarily this would be a job for parallel
, but I want to display them in the stage view. In the mock up below:
- Build #4 shows what normally happens. Job
two
fails sothree
does not run. - I Photoshopped Build #6 to show what I would like to see. Job
two
fails and is displayed as such, butthree
still runs. The real Jenkins would probably display the entire Build #6 tinged slightly red, which is of course fine.
Best Answer
This is now possible. Below is an example of a declarative pipeline, but
catchError
works for scripted pipelines as well.In the example above, all stages will execute, the pipeline will be successful, but stage 2 will show as failed:
As you might have guessed, you can freely choose the
buildResult
andstageResult
, in case you want it to be unstable or anything else. You can even fail the build and continue the execution of the pipeline.Just make sure your Jenkins is up to date, since this is a fairly new feature.
EDIT: You need "Pipeline: Basic Steps" 2.16 (May 14, 2019)