Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata

*nix/Mac Auto-Upgrade With Container

If you run Jenkins with java -jar jenkins.war, Jenkins will be able to update itself from the Manage Jenkins page. This is the simplest way to do automatic upgrades.

If you've installed via the OS X installer, the 'jenkins' running the process does not own the .war file. To get auto-upgrade working, just fix the permissions so the jenkins user can write the WAR (in /Applications/Jenkins).

If you run Jenkins in other servlet containers, here is a simple set of steps to create a Jenkins job to semi-automate Jenkins Updates written by Rolf. The local paths need to be changed to reflect the individual setup configuration.

cd /tmp
rm -f jenkins.war.backup
cp /usr/local/jboss/server/default/deploy/jenkins.war /tmp/jenkins.war.backup
rm -f jenkins.war
wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war
nohup /usr/local/bin/copywar.sh > /tmp/copywar.out 2>&1 &

copywar.sh contains this:

#!/bin/bash
sleep 20
cp /tmp/jenkins.war /usr/local/jboss/server/default/deploy

The reason this in in a separate script with a nohup is so that the job can complete properly before Jenkins deployment begins. In Vista it needs to be set to "Run with highest Authority," but should have no trouble running in Windows XP.

Debian Package Upgrade

Using the Upgrade-Button from within Jenkins (available since 1.318) will not work if Jenkins was installed from a Debian package (results in permission denied errors when trying to download the new WAR file)!

This update procedure works, if you installed Jenkins from a Debian package (see http://weblogs.java.net/blog/kohsuke/archive/2008/06/debian_packages.html for more information):

aptitude update
aptitude install jenkins

Windows Auto-Upgrade

If you install Jenkins as a Windows service, Jenkins will be able to update itself from the Manage Jenkins page. This is the simplest way to do it.

Alternatively, here is a similar script to the one above for Windows users.  It is a batch file and can be setup as a scheduled task to update Jenkins on a regular schedule. This particular script keeps a backup of the most recent copy of jenkins.war in the same directory as the auto updater does. Because this script starts and stops the Jenkins service for you, it does require that it be run as an Administrator on Windows 2008 and above. It does delete the complete exploded war file from the deployment location, so be careful if you save any configuration files to that directory.

@rem --[ This code block detects if the script is being running with admin PRIVILEGES If it isn't it pauses and then quits]-----
@echo OFF
net session > NUL 2> NUL
IF %ERRORLEVEL% EQU 0 (
    ECHO Administrator PRIVILEGES Detected!
) ELSE (
   echo.
   echo ####### ERROR: ADMINISTRATOR PRIVILEGES REQUIRED #########
   echo This script must be run as administrator to work properly!  
   echo If you're seeing this after clicking on a start menu icon,
   echo then right click on the shortcut and select "Run As Administrator".
   echo ##########################################################
   echo.
   PAUSE
   EXIT /B 1
)

@echo off
REM === Some modifications need to be made for your setup options ===
set deployLoc="C:\Program Files\Jenkins"
set jenkinsHome="C:\Program Files\Jenkins"
set jenkinsURL="http://mirrors.jenkins-ci.org/war/latest/jenkins.war"
set WGET="C:\Program Files\GnuWin32\bin\wget.exe"

Echo === get new files ===
%WGET% -O %deployLoc%\jenkins.war.latest --no-check-certificate %jenkinsURL%
IF %ERRORLEVEL% EQU 0 (
   echo Download successful
) ELSE (
   echo ####### ERROR: DOWNLOAD FAILED #########
   PAUSE
   EXIT /B 1
)

Echo === Stopping Current Jenkins Service ===
sc stop Jenkins

Echo === Sleeping to wait for file cleanup ===
ping -n 4 127.0.0.1 > NUL

Echo === clean files ===
copy /Y %deployLoc%\jenkins.war %deployLoc%\jenkins.war.bak"
del %deployLoc%\jenkins.war

Echo === make room to explode new war file ===
RD /s /q %jenkinsHome%\war

Echo === rename new war file ===
move /Y %deployLoc%\jenkins.war.latest %deployLoc%\jenkins.war

Echo *** Starting new upgraded Jenkins
sc start Jenkins

Echo *** Sleeping to wait for service startup
ping -n 4 127.0.0.1 > NUL

  • No labels

6 Comments

  1. Unknown User (imakowski)

    I have an issue because Manage Jenkins don't show me an update for 1.509.3. My current configuration is Jenkins LTS 1.509.2. How to force to show upgrade button? This is second time when I have this issue. Could you please help me? I have Jenkins installed as windows service

  2. Unknown User (mhallak)

    I understand how to update a Jenkins master. What about the slaves? It would be comforting to mention them. If it is with JNLP then should we download the new slave?

  3. Unknown User (remik)

    Please note that AT windows command will always fail these days ergo your script will never detect administrator privileges.


    The AT command has been deprecated. Please use schtasks.exe instead.
    The request is not supported.


    And SCHTASKS will always success since luser accounts can schedule tasks by default.

    1. Unknown User (f00f)

      Thanks for pointing that out. I've updated the script to use net session instead.

      That seems to be the most reliable way nowadays.

  4. Unknown User (xinjia)

    I  run Jenkins with java -jar jenkins.war, and start the auto upgrade from the Manage Jenkins page. 

    However, is there any option to disable the auto upgrade?

    1. Unknown User (f00f)

      Upgrade from within Jenkins does not work for me, and I don't want to mess around with my setup. If it works for you I guess it's fine.