Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot Set the Job status back to Success in Jenkins Pipeline [duplicate]

I'm using the env variable "currentBuild.result" to modify the overall job status of a Jenkins job.
I can set it to a failure using

currentBuild.result = 'FAILURE'

and I can set it to Aborted using

currentBuild.result = 'ABORTED'

but I cannot clear these back to success using

currentBuild.result = 'SUCCESS'

This is driving me nuts, Any idea what I'm doing wrong here and any pointers on how to set the overall job status to Success after they have been set to some other state?

Appreciate any pointers in advance!

like image 506
Jose Avatar asked Dec 11 '18 19:12

Jose


People also ask

How do I stop Jenkins pipeline if stage fails?

Alternatively you can call error(String message) step to stop the pipeline and set its status to FAILED . For example, if your stage 1 calls error(msg) step like: stage("Stage 1") { steps { script { error "This pipeline stops here!" } } }


1 Answers

You can only set build status to worse than it value. Meaning you can set SUCCESS -> ABORTED, but can't set FAILED -> SUCCESS.

like image 97
Snehalkumar Mahale Avatar answered Sep 30 '22 04:09

Snehalkumar Mahale