Upgrading Jenkins war file the quick and dirty way

#!/bin/bash

set -e

if [ $# -eq 0 ]; then
    echo "New Jenkins version number missing"
    exit 1
fi

VERSION=${1}

set -x

cd /usr/share/jenkins/
wget http://updates.jenkins-ci.org/download/war/${VERSION}/jenkins.war -O jenkins.war-${VERSION}
rm jenkins.war && ln -s jenkins.war-${VERSION} jenkins.war
service jenkins restart

The above bash script will download a given version of the jenkins.war file and symlink it into place before restarting the jenkins service.

Assumptions made:

  • The jenkins.war file is installed to /usr/share/jenkins
  • The server is using upstart for running services
  • User input is sane – there is no validation or sanitisation