How to update jenkins
How to update jenkins
Methods for upgrading Jenkins instance
On production environment it’s very important the Jenkins remains updated with so that it gets all it’s required security updates/patches time to time.
We should use always the LTS release over production environment as they are long term releases and are stable.
There are different mechanism available to upgrade the Jenkins server and can be chooses as per the infrastructure availability.
Upgrade prerequisite:-
Method to check currently installed Jenkins version
So here we can see the current version is 2.190.3
Methods available to update Jenkins
Upgrading using Jenkins yum update command
command to update Jenkins sudo yum update jenkins
This command will fetch out all the updates and prompt us to whether we want to install the updates or not just press the option Y
Once Y option is chosen to install the updates it will start fetching the updates and finally it will update it update Jenkins to the latest version as shown below here it is upgraded to latest version i.e. 2.222.3-1.1
Upgrading using by downloading the war file
Jenkins can be upgraded by downloading the war file also for this go to the location where Jenkins.war file resides and then get the download the link required version war file from http://mirrors.jenkins.io/war-stable/
Before this please take the backup of existing Jenkins war file.
Once the specific version Jenkins war file is downloaded we can restart Jenkins and it should take the updated Jenkins version now.
Upgrading Jenkins from Manage Jenkins.
Jenkins can be upgraded from Manage Jenkins menu also just go to manage Jenkins option click on Upgrade Automatically.
Once clicked on upgrade automatically option it will take us to the upgrade progress screen once completed it should success.
Once update we can see the Jenkins version as per any of the method mentioned earlier.
So we can see Jenkins has been upgraded from 2.19 to 2.222… Version.
Jenkins : Automated Upgrade
*nix/Mac Auto-Upgrade With Container
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.
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.
@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 === Stopping Current Jenkins Service ===
sc stop Jenkins
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
Document generated by Confluence on Sep 07, 2021 13:08
Update Jenkins from a war file
I have a machine with Ubuntu 12.04 and have installed Jenkins ver. 1.424.6 using apt-get based on *this guide*, but there is a new version:
If I press download, I get a jenkins.war file. but how do I use that for upgrading my current installation? or is that not possible before the apt repositories gets updated?
14 Answers 14
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
You can overwrite the existing jenkins.war file with the new one and then restart Jenkins.
If you have installed Jenkins via apt-get, you should also update Jenkins via apt-get to avoid future problems. Updating should work via «apt-get update» and then «apt-get upgrade».
For details visit the following URL:
by far the easiest way to upgrade on linux, works like a charm everytime.
after taking backup overwrite the war file and restart the jenkins service.
Though I wouldn’t consider this as a valid answer to OP’s question, I’d still emphasize that the best way to deploy Jenkins (and likely most if not all libraries/packages/software) on Ubuntu is to leverage aptitude (or apt-get) management system.
So if by any chance you actually did use this approach, you’d simply do a apt-get upgrade jenkins
You can even run the command from the
I use this groovy script to download new war file
We host it on windows 2008 and tomcat, I use sc query, sc config, sc stop, sc start to manage windows services
This could be done in two ways
1st Method
The common location of Jenkins war file on the ubuntu server is:
Jump to jenkins home directory
Stop the jenkins server
Move existing jenkins war file
Download latest jenkins war file
Start the Jenkins server
Everything should be good now.
Troubleshooting steps
If you are running jenkins using root permissions, (which you should not be doing), you need to change the jenkins.war permissions.
You can optionally restart the jenkins server using below command:
$ sudo /etc/init.d/jenkins restart
2nd Method
On ubuntu, you can also try the below two commands to update everything:
How to Upgrade Jenkins to New Version and Update Plugins
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.
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.
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.
Next, copy the newly downloaded war file to the /usr/lib/jenkins directory.
Next, restart the Jenkins service as shown below. Use either systemctl or service command.
This shows that the Jenkins server is running with the new var file.
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.
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.
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.
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
The list of plugins under the “Updates” tab will have the following 4 columns:
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
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.
Upgrading Jenkins and Post Upgrade Activities
As we know Jenkins is one of the most used opensource automation tools. Since it is highly reliable and stable, it is highly recommended for enterprise CICD and another automation purpose. Although it is highly reliable and stable, we need to be careful when we upgrade Jenkins to new versions of Jenkins. Especially, when we have a big set of plugins, we should take care of the stability of Jenkins. So, in this article, we will discuss Upgrading Jenkins and Post Upgrade Activities.
Table of Contents
Step by Step Upgrading Jenkins.
Just simply follow the following steps to upgrading Jenkins for respective Operating system.
For Linux Based Operation system.
Step 1: Check the current version of your Jenkins:
Go to your Jenkins URL and scroll down to the right bottom corner to see the current version of your Jenkins.
Simply run the following command on your Jenkins’ server to check your Jenkins Version
Step 2: Get the downloadable war file:
Go to Your Jenkins Home. Then, Go to Manage Jenkins and there you will see the new version notification with the download button as shown in the screenshot.
So, we have the version 2.222.1 to upgrade your Jenkins. Simply click the download button and get the war file or copy the link of the war file (Right-click and “Copy link address”). Then Run wget command to download the content.
Step 3: Update the Jenkins libs and binaries
If you have installed the Jenkins with Yum, just run
If the Jenkins were installed with apt, then run
So, what ever package manager you used to install, just update once with the file.
Step 4: Find the Path of the executable-war file.
To know the path of Jenkins’s executable-war file, go to Jenkins Home, then, Click Manage Jenkins, Then, click System Information. Then, you will see the path of an executable war file as shown in the below screenshot.
executable-war file path of Jenkins
Step 5: Replace the newly downloaded war file.
Take a backup of the jenkins.war file from the executable-war path.
Now just replace the newly downloaded war file from the executable-war file path.
Step 6: Gracefully restart the Jenkins
Now, simply restart the Jenkins to complete the upgrading process by running following command.
That’s is, Now the Jenkins is upgraded to the newer version. You can check it by the cli.jar command as per the Step 1.
For Windows Based Operating system
In windows. Upgrading Jenkins is simple. Most of the time, you will see the button right next to the New version notification on Manage Jenkins page. Just click it to Upgrade. But sometime, the button will not be available. In that case, just follow the following steps.
For MacOS.
In MacOS, it is exactly same as Linux based OS. In simple steps
Now, we should take care of some activities to ensure the stability and reliability of your Jenkins.
Post Upgrade Activates.
We might not need all the following activities need to be done but do check all the listed activities after the upgrade of Jenkins.
These are the major activities that need to be verified right after upgrading Jenkins. Once after verifying all the above activities, you can say that you upgrade process is successful.
Conclusion
In this article, we have discussed the process of Upgrading Jenkins and some Post Upgrade tasks on various operating system. There are always corner cases and exceptional situations which might block our upgrade process. As we already discussed, Jenkins is the most popular opensource automation tool and we have huge community to support Jenkins issues. If you couldn’t find answers, Comment below your situation and DigitalVarys will try to help you in that. Stay tuned and subscribe DigitalVarys for more articles and study materials on DevOps, Agile, DevSecOps and App Development.
Experienced DevSecOps Practitioner, Tech Blogger, Expertise in Designing Solutions in Public and Private Cloud. Opensource Community Contributor.