Christian Oestreich

   two guys in design - software.development.professional

Jenkins Upgrade Script

| Comments

I got really tired of manually upgrading Jenkins on my build server so I wrote a little bash script to do it for me.

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/bash
 echo "stopping tomcat"
 sh /etc/init.d/tomcat6 stop
 cd /var/lib/tomcat6/webapps
 echo "removing jenkins"
 rm -rf jenkins
 rm -rf jenkins.war
 echo "downloading latest jenkins"
 wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war
 echo "starting tomcat"
 sh /etc/init.d/tomcat6 start
 cd ~
 echo "done"

I call mine upgrade.sh.  Make sure to set the permissions on the file to something executable; I set mine to chmod 775.  Then you can run this by typing the following line.  It should be run with elevated permissions so it can interact with processes like starting and stopping the server.

$  sudo ./upgrade.sh

You may have to tweak the locations to suit your needs.  Another thing you may want to do is move your jenkins folder instead of removing it, but since config is stored else where you should be okay to just remove the web app and put the new war in it’s place.

This script assumes you are running Jenkins under Tomcat and not standalone.

Comments