Jenkins keeps restarting due to System.exit in a Pipeline


Your Jenkins instance keeps shutting down, or it shut down one time, and it’s not clear what is the root cause, but an administrator recently approved a new method under Manage Jenkins -> In-process Script Approval for System.exit.

It is possible that a Pipeline build called the method System.exit, and then one of the Jenkins administrators approved the System.exit method from Manage Jenkins -> In-process Script Approval, after which point any time a Pipeline calls that method, it will exit the JVM that is running Jenkins itself.



Option A ) If your Jenkins instance is able to fully load, then check under Manage Jenkins -> In-process Script Approval and ensure that you do not have the method java.lang.System exit in the approved methods:

system.exit script approval

If you have that entry, you can clear it by using the Clear Approvals or Clear only dangerous Approvals buttons.

Option B ) If your Jenkins instance keeps restarting, check the following file: JENKINS_HOME/scriptApproval.xml, and look for the line with staticMethod java.lang.System exit int

    <string>staticMethod java.lang.System exit int</string>

If you see that line, you should delete the <string>staticMethod java.lang.System exit int</string> line, and start Jenkins again.


Tested product/plugin versions

Script Security plugin version 1.51
CloudBees Core on Traditional Platforms

Note that with Script Security plugin version 1.58 (18 Apr 2019) Administrators are no longer able to approve System.exit(int) in the first place from In-process Script Approval, so this issue would be avoided.

Have more questions?


Please sign in to leave a comment.