Under certain conditions I want to fail the build. How do I do that?
I tried:
throw RuntimeException("Build failed for some specific reason!")
This does in fact fail the build. However, the log shows the exception:
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use new java.lang.RuntimeException java.lang.String
Which is a bit confusing to users. Is there a better way?
You can use the error
step from the pipeline DSL to fail the current build.
error("Build failed because of this and that..")
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