6

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!

Jose
  • 1,333
  • 5
  • 20
  • 38

2 Answers2

5

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

3

This can be done using the rawBuild state.

import hudson.model.Result
currentBuild.rawBuild.@result = hudson.model.Result.SUCCESS

Found the answer from this question. How to manipulate the build result of a Jenkins pipeline job?

Jose
  • 1,333
  • 5
  • 20
  • 38