user1164061
user1164061

Reputation: 4342

How to shutdown my Jenkins safely?

I run Jenkins in its own container. I use the command "nohup java -jar jenkins.war --httpsPort=8443".

How do I shut it down safely? Right now, I use the kill command to kill the process.

Upvotes: 92

Views: 205324

Answers (9)

Muthaiah PL
Muthaiah PL

Reputation: 1158

  1. jenkinsUrl/safeRestart - Let you to wait for running JOBS to get complete and do a RESTART.
  2. jenkinsUrl/restart - Do a restart immediately without waiting for the jobs which are running currently.
  3. jenkinsUrl/exit - It stops/shutdown the JENKINS services
  4. jenkinsUrl/reload - To reload the configuration changes.

Upvotes: 31

Shaiju T
Shaiju T

Reputation: 6609

Immediately shuts down Jenkins server.

In Windows CMD.exe, Go to folder where jenkins-cli.jar file is located.

C:\Program Files (x86)\Jenkins\war\WEB-INF

Use Command to Safely Shutdown

java -jar jenkins-cli.jar -s http://localhost:8080 safe-shutdown --username "YourUsername" 
--password "YourPassword"

The full list of commands is available at http://localhost:8080/cli

Credits to Francisco post for cli commands.

Reference:

1.

Hope helps someone.

Upvotes: 1

Paul
Paul

Reputation: 7325

You can also look in the init script area (e.g. centos vi /etc/init.d/jenkins ) for details on how the service is actually started and stopped.

Upvotes: 2

Noam Manos
Noam Manos

Reputation: 16971

Create a Jenkins Job that runs on Master:

java -jar "%JENKINS_HOME%/war/WEB-INF/jenkins-cli.jar" -s "%JENKINS_URL%" safe-restart

Upvotes: 2

mcane
mcane

Reputation: 1736

If you would like to stop jenkins and all its services on the server using Linux console (e.g. Ubuntu), run:

service jenkins start/stop/restart

This is useful when you need to make an image/volume snapshot and you want all services to stop writing to the disk/volume.

Upvotes: 67

tcbcw
tcbcw

Reputation: 1577

Use http://[jenkins-server]/exit

This page shows how to use URL commands.

Upvotes: 132

Francisco
Francisco

Reputation: 4110

The full list of commands is available at http://your-jenkins/cli

The command for a clean shutdown is http://your-jenkins/safe-shutdown

You may also want to use http://your-jenkins/safe-restart

Upvotes: 25

sti
sti

Reputation: 11075

You can kill Jenkins safely. It will catch SIGTERM and SIGINT and perform an orderly shutdown. However, if Jenkins was in the middle of building something, it will abort the builds and they will show up gray in the status display.

If you want to avoid this, you must put Jenkins into shutdown mode to prevent it from starting new builds and wait until currently running builds are done before killing Jenkins.

You can also use the Jenkins command line interface and tell Jenkins to safe-shutdown, which does the same. You can find more info on Jenkins cli at http://YOURJENKINS/cli

Upvotes: 8

gareth_bowles
gareth_bowles

Reputation: 21130

Yes, kill should be fine if you're running Jenkins with the built-in Winstone container. This Jenkins Wiki page has some tips on how to set up control scripts for Jenkins.

Upvotes: 19

Related Questions