Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failing a build in Jenkinsfile

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?

like image 603
oillio Avatar asked Jun 07 '16 17:06

oillio


1 Answers

You can use the error step from the pipeline DSL to fail the current build.

error("Build failed because of this and that..") 
like image 58
StephenKing Avatar answered Sep 21 '22 18:09

StephenKing