I have a pipeline which checks some preconditions and calls error if they are not met, later stages in this pipeline can set the build status to unstable (or even back to success after some scripted retries) so calling assertJobStatusFailure() in the test fails because the later steps are being evaluated and setting the status even though they wouldn't do in a real run
I was testing a pipeline which calls
error
and noticed the call stack contained the steps after it, this seemed wrong so I double checked in JenkinsUsing the following pipeline
I ran it and indeed the "baz" stage does not occur and the output is
But if I run a test on the pipeline script
the call stack shows the remaining steps
To give an example where this causes problems
I have a pipeline which checks some preconditions and calls error if they are not met, later stages in this pipeline can set the build status to unstable (or even back to success after some scripted retries) so calling
assertJobStatusFailure()
in the test fails because the later steps are being evaluated and setting the status even though they wouldn't do in a real run