Search code examples
jenkinsrestartshutdown

What happens to running Jenkins builds when Jenkins is preparing for safe shutdown?


Does the current running build on Jenkins still completes when you click on "Prepare for Shutdown"?

I want to take admin control on Jenkins to make some config changes so I am clicking on "Prepare for Shutdown" but I want to ensure it completes the current builds before shutting down.


Solution

  • As cloudbees describes,

    The Prepare for Shutdown feature prevents any more jobs from running. When all jobs are finished, you still need to restart/stop the instance manually.

    It is the http://<jenkins.server>/quietDown command

    They also describe various other options:

    http://<jenkins.server>/restart
    http://<jenkins.server>/safeRestart
    http://<jenkins.server>/exit
    http://<jenkins.server>/safeExit
    http://<jenkins.server>/quietDown
    http://<jenkins.server>/cancelQuietDown
    

    Personally, I think they should have called it something different, like setToIdle or blockQueue

    In your case, you will want to quietDown, then safeExit or safeRestart (to be safe). Normally you can just safeRestart.

    There are some nuances regarding pipelines or jobs that trigger downstream jobs. There are some plugins that add a button to achieve the same effect.
    Saferestart just adds buttons.
    Lenient shutdown talks about downstream jobs and also lets you manage nodes. There's other to stop all jobs (bruteforce) and re queue them after (nice admin). Others also manage the queue.

    IIRC, pipelines will complete the stage and can resume after the restart or cancel.