Jenkins is an open source automation server, which will help you to build, deploy and automate your enterprise application.
If you are using Jenkins for production deployment, it is very critical to keep it up-to-date with the latest version.
Jenkins has a very active open source community. They constantly release new versions with lot of new features and bug fixes.
In this tutorial, we’ll explain how to upgrade your Jenkins to a newer version, and update all the plugins accordingly.
Identify Current Jenkins Version
To identify your current version of Jenkins, you can do one of two things.
From the Jenkins UI, from any screen, if you look at the bottom right corner, you’ll see the current version of the Jenkins that you are running.
Or, login to the Jenkins server, and use the jenkins-cli.jar and execute the following to get the current version from the command line.
java -jar jenkins-cli.jar -s http://localhost:8080/ version
In my case, the current version that I’m running is: Jenkins ver. 2.5
When you login to Jenkins UI, and click on “Manage Jenkins” menu item, if you need an upgrade, it will display the following message at the top saying that a new version of Jenkins is available for download.
In this example, the new version that is available for dowload is: Jenkins ver. 2.9.
So, I’ll be upgrading from version 2.5 to 2.9. Please note that the upgrade procedure is very similar for any version of Jenkins.
BTW, you should use the admin account that you created during Jenkins Security Setup to login to the GUI.
Download New Jenkins War File
When you click on the download link from the above message, it will not download the whole Jenkins Installer. Instead, it will download only the jenkins.war file.
You can just copy the link to download from your Jenkins GUI, and go to command prompt, and use wget to download the war file.
cd /downloads wget http://updates.jenkins-ci.org/download/war/2.9/jenkins.war
Note: If you’ve installed Jenkins as part of yum install, then you should do “yum update jenkins”, which will upgrade the war file accordingly. Also, if you’ve previously installed Jenkins using yum, but yum repository still doesn’t have the latest version of Jenkins, you can still go-ahead and download the war file and upgrade it manually on top of the yum-jenkins-installation as explained in this article. Eventually when the repository catches up with the latest version, you can always do yum update jenkins at that time.
Install the New Jenkins War File
On your server, jenkins.war file is located under /usr/lib/jenkins directory.
Before you copy the new version of the jenkins war file, take a backup of the existing version of jenkins war file.
cp /usr/lib/jenkins/jenkins.war /downloads/jenkins.war.previous.version
Next, copy the newly downloaded war file to the /usr/lib/jenkins directory.
cp /downloads/jenkins.war /usr/lib/jenkins/
Next, restart the Jenkins service as shown below. Use either systemctl or service command.
systemctl stop jenkins systemctl start jenkins
This shows that the Jenkins server is running with the new var file.
# systemctl status jenkins ? jenkins.service - LSB: Jenkins Continuous Integration Server Loaded: loaded (/etc/rc.d/init.d/jenkins) Active: active (running) since Sun 2016-06-11 20:33:16 PDT; 3s ago Docs: man:systemd-sysv-generator(8) Process: 32453 ExecStop=/etc/rc.d/init.d/jenkins stop (code=exited, status=0/SUCCESS) Process: 32473 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS) Memory: 461.2M CGroup: /system.slice/jenkins.service +-32498 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --log... Jun 10 20:33:15 devdb systemd: Starting LSB: Jenkins Continuous Integration Server... Jun 10 20:33:15 devdb runuser: pam_unix(runuser:session): session opened for user jenkins by (uid=0) Jun 10 20:33:16 devdb runuser: pam_unix(runuser:session): session closed for user jenkins Jun 10 20:33:16 devdb jenkins: Starting Jenkins [ OK ] Jun 10 20:33:16 devdb systemd: Started LSB: Jenkins Continuous Integration Server.
Post Upgrade Tasks
After the upgrade, login to your Jenkins UI and verify that you see the new version number at the bottom right corner.
Or, execute the following command from the command line, to see the new version.
java -jar jenkins-cli.jar -s http://localhost:8080/ version
After the upgrade, I see the new version as: Jenkins ver. 2.9
Also, now when you go to “Manage Jenkins” page, you’ll not see that upgrade available message anymore.
But here you’ll see any additional tasks that you may still have to do on your Jenkins server.
In this example, I see the following that says that I should consider turning on the agent to master security subsystem.
To do this, go to Configure global security -> From this page, scroll down to the bottom section for “Plugin Manager”, where “Enable Slave -> Master Access Control” is not checked. Click on the check-box to select this option.
When you select the “Enable Slave”, it will also show this right below it: “Rules can be tweaked here.” Now, click on Save.
From the rules page, you can tweak the settings for this particular configuration.
Additional Post Upgrade Tasks
When you go to “Manage Jenkins”, depending on your previous Jenkins version that you were running, you might also see this message: You have data stored in an older format and/or unreadable data.
This happens when Jenkins decide to change how the data is stored in the backend. After the upgrade, the data is still stored in the old format on the disk, but during the load, it will convert it to the new format for usage. This is good if you decide to downgrade Jenkins to older version for some reason. But, ideally, once you upgrade and confirm that everything is working as expected, you should upgrade the the data to the new format.
Click on “Manage” next to it, which will show the following UI -> Click on “upgrade”
After the upgrade, this “Manage old data” page will say “No old data was found.”
Now, when you go back to the manage jenkins page, you’ll not see that warning message anymore.
Upgrade Jenkins Plugins (After Jenkins Upgrade)
Anytime you upgrade Jenkins to a new version, use that opportunity to upgrade all your plugins to the new version, as some plugins might not work with the new Jenkins version and might need upgrade.
From Manage Jenkins, in the “Manage Plugins” section, you’ll see “(updates available)” in read which indicates that there are plugins that needs to be upgrade: Add, remove, disable or enable plugins that can extend the functionality of Jenkins. (updates available)
List of Plugins to be Upgraded
From Jenkins, click on “Manage Jenkins” -> click on “Manage Plugins” -> from this page, under the “Updates” tab, this will list all the plugins that needs to be upgraded.
The list of plugins under the “Updates” tab will have the following 4 columns:
- Install – Checkbox to select either all the plugins or select them individually
- Name – Plugin Name
- Version – New version number of that particular plugin that is available for you to download and install
- Installed – The old version number of that particular plugin that is currently installed on your system.
At the bottom, it will say “Update information obtained: 23 hr ago “. Click on “Check Now” button right next to it, to check for new updates again, as we need to do this after any Jenkins Upgrade.
Upgrade Jenkins Plugins
Scroll down to the bottom of the page, and click on “Select All” -> Now click on “Download now and install after restart” button.
This will start updating all the plugins.
While it is upgrading the plugins, it will show the following check-box at the bottom of the page, select this check-box: Restart Jenkins when installation is complete and no jobs are running.
If the auto refresh is not enabled (it will say on the top right corner of the page), then you have to manually refresh the page to see if the upgrade is completed. You have to login again after the upgrade.
Jenkins and Plugins Upgrade Completed
After all the plugins are upgraded, you will not see “(updates available)” warning next to “Mange Plugins”. Also, when you go to the plugin manager and click on “Updates” tab, it will say “no updates”!
If you’ve taken care of all post upgrade tasks, you’ll not see any warning message under the “Manage Jenkins” screen as shown below.