Jenkins keeps restarting due to System.exit in a Pipeline

Issue

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.

Environment

Resolution

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

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

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

  <approvedSignatures>
    ...
  </approvedSignatures>

Tested product/plugin versions

Script Security plugin version 1.51
CloudBees Core on Traditional Platforms 2.150.3.2

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?

0 Comments

Please sign in to leave a comment.