How can I prevent jenkins from starting new jobs after a restart?

Issue

You want to prevent any jobs from running after Jenkins starts up. This could be necessary to troubleshoot or help recover from a performance issue, or to validate an upgrade or configuration change before releasing a master for regular use.

Environment

Resolution

Any builds that are in the pending queue when Jenkins is restarted will remain in the queue and potentially be started after Jenkins finishes loading. In addition, scheduled jobs or jobs triggered externally could also start at any time. In order to prevent Jenkins from executing any jobs, you need to put it in “quiet down” mode when it starts up. There are two ways you can do this.

  1. You can install and use the Quiet Start plugin. This will give you a UI option to restart Jenkins and have it be in “quiet down” mode when it starts up. This plugin is only available to users of CloudBees Core, CloudBees Jenkins Enterprise, and CloudBees Jenkins Platform.
  2. You can create a Groovy init script that will put Jenkins in “quiet down” mode when it starts. This solution may be required if you are suffering from a performance issue and cannot access the Jenkins UI. It is also the only solution that will work for users of Jenkins LTS or CloudBees Jenkins Distribution. Create a file named quiet-start.groovy and place it in the $JENKINS_HOME/init.groovy.d/ directory. You may have to create this directory if it does not already exist. The file should contain the following:
import jenkins.model.Jenkins

// Go into quiet mode
Jenkins.instance.doQuietDown()

Regardless of the solution you use, when Jenkins starts up you will see a red banner at the top of the page which says, “Jenkins is going to shut down,” along with a similar message in the Build Queue. There will be a ‘Cancel’ button which an administrator can click to cancel “quiet down” mode and allow builds to resume.

Have more questions?

0 Comments

Please sign in to leave a comment.