Skip to content

Instantly share code, notes, and snippets.

@alexmerser
Forked from philosuke/upgrade_jenkins.sh
Last active August 29, 2015 14:24
Show Gist options
  • Save alexmerser/1444c2754ef25b5d318c to your computer and use it in GitHub Desktop.
Save alexmerser/1444c2754ef25b5d318c to your computer and use it in GitHub Desktop.
#! /bin/sh
# directory that contains the jenkins.war
JENKINS_WAR_DIR=/usr/share/jenkins
# Absolute path the jenkins.war
JENKINS_WAR=${JENKINS_WAR_DIR}/jenkins.war
# Absolute path the jenkins.war for backup
JENKINS_BACKUP_WAR=/tmp/jenkins.war.bak
# latast jenkins.war
JENKINS_LATEST_WAR_URL=http://updates.jenkins-ci.org/latest/jenkins.war
# Absolute path the downloaded jenkins.war
DOWNLOADED_WAR=${WORKSPACE}/jenkins.war
# backup
rm -f ${JENKINS_BACKUP_WAR}
cp ${JENKINS_WAR} ${JENKINS_BACKUP_WAR}
# get latest war
rm -f ${DOWNLOADED_WAR}
wget ${JENKINS_LATEST_WAR_URL} --no-check-certificate
# replace to the new war
rm -f ${JENKINS_WAR}
cp ${DOWNLOADED_WAR} ${JENKINS_WAR}
#safe restart
service jenkins restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment