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 controller for regular use.
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.
Even with Quiet Down mode enabled on boot, there are still certain conditions where some of the pipelines that were running prior to the restart can still start executing upon boot. If these running pipelines prevent the controller from fully starting, you will need to stop the controller and move that build away from the filesystem which will be inside of $JENKINS_HOME/jobs/$JOB/builds/$BUILD_NUMBER as documented in step #7 of I have a stuck Pipeline and I can not stop it. One way to prevent this issue is to stop all running pipelines before restarting if possible.
|
-
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.
-
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. 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.
After Jenkins has started, you may find that you want to purge all builds in the build queue. To do this, you can easily do so by following our How can I purge/clean the build queue? article.