Published on December 12, 2017
Notice: This post is more than a year old. Some of the content might be outdated.

Jenkins quiet startup

Preventing Jenkins from running jobs after a restart

You don’t always want Jenkins to start running jobs right after it starts. Sadly, starting up in a dormant state isn’t a built-in feature, unless you’re running CloudBees Jenkins Enterprise. However, there’s little a clever script can’t solve.

This is a short post about getting Jenkins to start in quiet mode, so it doesn’t run any builds. After a series of upgrades, we wanted to verify Jenkins was correctly configured. However, we didn’t want builds to start running while we were still busy.

To solve this, I hacked together a simple Groovy script that puts Jenkins in quiet mode. By setting it up as an initialization script, we have ourselves a sleeping Jenkins on startup. I later fleshed out the script so it can also wake up Jenkins after a few minutes:

import jenkins.model.Jenkins

// Go into quiet mode

// Wake up after an async wait
Thread.start {
  // doCancelQuietDown requires admin privileges

  // Sleep 5 minutes, in milliseconds
  Thread.sleep(5 * 60 * 1000)

To set it up as a Jenkins initialization script, save it as $JENKINS_HOME/init.groovy or place it as a *.groovy file in the $JENKINS_HOME/init.groovy.d/ directory.

When Jenkins is restarted, it will now start up in quiet mode. You can tell by the giant red notification at the top of the page stating “Jenkins is about to shut down”. No worries, it isn’t. The message will disappear once quiet mode gets turned off again.

Author: Thierry Lacour

Read more about Thierry

Related Stories

Related Stories


Developing Embedded Software with DevOps

A guide on how to improve development processes

How to visualize project health in Jira

Tips to improve project management in the Atlassian suite

Testing Kubernetes Deployments within CI Pipelines

Low overhead, on-demand Kubernetes clusters deployed on CI Workers Nodes with KIND