Marking Jenkins build UNSTABLE from environment inject groovy script
Posted by Admin • Wednesday, March 23. 2016 • Category: Code and Hacks, DevOps
The way we use the Jenkins "Prepare an environment for the run" feature of the Environment Inject Plugin is this: we use the "Evaluated Groovy Script" to retrieve some info from a successful run of some other job (svn revisions, environment vars, whatever) in order to make it available to the environment of the current build. But what if that other job hasn't run successfully (yet)? I'd like to distinguish this "soft failure" from a real problem, so I'd like the build status to be "UNSTABLE".
Here is how to do that in env inject:
However, that will not terminate the build. If you want to stop execution at this point, you'll have to put conditional logic in the job steps (but you can set a variable in EnvInject, and, for example, check it using Conditional Step)currentBuild.@result = hudson.model.Result.UNSTABLE
Alternatively, to mark the build aborted and terminate immediately instead:
Screenshot:
Continue reading "Marking Jenkins build UNSTABLE from environment inject groovy script"