DevOps Stack Exchange is a question and answer site for software engineers working on automated testing, continuous delivery, service integration and monitoring, and building SDLC infrastructure. It only takes a minute to sign up.
I need to make some configuration changes on our Jenkins instance that will involve restarting Jenkins a couple of times. However, our developers are committing frequently enough that I haven't seen Jenkins without jobs running in three days.
Is there a native way (either through the GUI or via command line) to safe-restart Jenkins? IE: wait for current jobs to finish before going down, and keep track of queued jobs to start once Jenkins comes back up.
I know there's a plugin but in order to install it I need to restart Jenkins...
JENKINS_URL can be specified via the environment
variable $JENKINS_URL. This environment variable is automatically set
when Jenkins fork a process during builds, which allows you to use
Jenkins CLI from inside the build without explicitly configuring the
NOTE: When running the safeRestart command, any jobs set to be executed during the restart will be queued up and executed when the server is back online. Make sure this does not cause any conflicts upon reboot!
I think this is a real problem that many are trying to solve. There are at times where it is preferable to restart Jenkins upon plugin installation. One of the suggestions that I can provide based on my experience is to:
Restrict access to the admin module so that not every developer can install plugins
Instruct developers on the downtime and inform them ahead of time
Install all the required plugins in bulk and restart Jenkins
Inform the developers that Jenkins is ready for use
I understand that this requires a manual effort and coordination. But this has worked so far so well in our project, thought no harm in mentioning.
Navigate to the Plugin Manager, then click on the Installed tab and scroll to the bottom. There should be a button there that says something along the lines of Restart Jenkins once no jobs are running.