I'm trying to fail a Build Flow Plugin job if a parameter isn't set. When I try:
final parameter = params['PARAMETER']
if (parameter.isEmpty()) {
out.println('Error: PARAMETER must be defined')
System.exit(1)
}
the entire Jenkins master dies (double plus ungood).
How do I get the job to fail without killing Jenkins?
Set the Result
on build.state
then return so as not to execute anything else:
import hudson.model.Result
final parameter = params['PARAMETER']
if (parameter.isEmpty()) {
out.println('Error: PARAMETER must be defined')
build.state.setResult(Result.FAILURE)
return
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With