-
Bug
-
Resolution: Fixed
-
Minor
-
Red Linux 7 (RHEL 7)
If I have a single stage pipeline that calls an sh script that deliberately fails, and I use try .. catch around the script, then the stage is marked as "green/success" in the pipeline, but it should be marked as "pink/failed."
However, if I then add a final additional stage, the original first stage (previous stage) will then correctly be marked as "pink/failed."
Here is some simple Jenkinsfile code that demonstrates the problem.
def machine1 = 'mymachine' node (machine1) { currentBuild.result='SUCCESS' stage "Stage One" try { sh "banana" } catch (err) { echo "Stage One Failed: ${err}" currentBuild.result='FAILURE' } // // We need this final stage to mark the end of the preceding stage, // so that the preceding stage's code will fail if its sh script fails // // stage "End" echo "We've reached the end of the '${env.JOB_NAME}' pipeline. The build has finished." }
You will see that the first (and only) stage is marked as green passed.
If you uncomment the penultimate line stage "End" then you will find the first stage to be marked as pink failed, which is correct.
Thanks
- is duplicated by
-
JENKINS-36522 An additional final stage is required to make previous stage fail when it should
- Closed