Sep 15, 2015

How to shutdown jenkins CI-Server in a clean state.

Jenkins is a CI-Server, which can check a multitude of SCM-Repositories like ( CVS, Subversion, git with a plugin and much more with plugins ).

The  server can be started standalone with the jar-call:

export PATH=/usr/local/bin:$PATH
export JAVA_HOME=/usr/java1.7/
export JENKINS_BASEDIR=/home/jenkins
export JENKINS_OPTS=--httpPort=$HTTP_PORT
$JAVA_HOME/bin/java -jar $JENKINS_BASEDIR/bin/jenkins.war $JENKINS_OPTS

In the running Jenkins-Server, the configured jobs are executed.

Now you can activate a shutdown in the WEB-GUI and wait until all jobs are finished.

The other way to shut down is via the jenkins-cli.jar

$JAVA_HOME/bin/java -jar $JENKINS_HOME/war/WEB-INF/jenkins-cli.jar -s http://localhost:$HTTP_PORT safe-shutdown --username user --password pw

This call waits until jenkins has finished all jobs and shuts the server down.

Other useful commands can be fetched with

 $JAVA_HOME/bin/java -jar $JENKINS_HOME/war/WEB-INF/jenkins-cli.jar -s http://localhost:$HTTP_PORT help