In this article, We are going to see the important locations of Jenkins and How to upgrade of the exits Jenkins server.

If you are new to the Jenkins so you can refer to my last article which on Installation of Jenkins.

This article is divide into the following 2 parts

  1. Jenkins Server File Hierarchy
  2. Upgrade The Jenkins Server

So lets start with the first part Jenkins server file hierarchy. In this part we are going to see the important files and directory’s of Jenkins server.

Jenkins Server File Hierarchy

First, we are going to check the home directory of our Jenkins.

grep jenkins /etc/passwd | cut -d: -f6 

In my case the Jenkins home directory is /var/lib/jenkins.

Important Jenkins files and directory’s in Linux

  1. /usr/share/jenkins – In this location Jenkins binary jenkins.war file is stored.
  2. /var/log/jenkins – In this location Jenkins logs are stored.
  3. /var/lib/jenkins – This is an important directory of Jenkins. This directory contains all the details related Jenkins. In this directory it will stored jobs, workspace, users, nodes details, plugins and job configurations.
  4. /run/jenkins – This directory contains PID of currently running Jenkins.

Upgrade The Jenkins Server

Step 1: Stop The Running Jenkins Server

For Jenkins version upgrade, We need to stop running Jenkins service using the following command

sudo systemctl stop jenkins      //For SystemD Based Linux 
OR 
sudo service jenkins stop        //For Init Based Linux

Step 2: Take Jenkins Server Backup For Safety

Already I explained the important directors of Jenkins Server in this article. We just need to take backup of Jenkins home directory. In my case the Jenkins home directory is /var/lib/jenkins. In your case it maybe the different.

cd /var/lib 
tar -cvzf jenkins_date.tar.gz jenkins/      // You can specific backup date 
mv jenkins_date.tar.gz $HOME

Step 3: Take The Backup Of Current Jenkins Version Binary

Now it’s time to take the backup of Jenkins current version binary using following commands

cd /usr/share/jenkins 
sudo mv jenkins.war jenkins.war.old

Step 4: Download The New Jenkins Version

We are downloading new version of Jenkins using the following commands

sudo wget https://updates.jenkins-ci.org/latest/jenkins.war

Step 5: Change The Ownership Of New Jenkins Binary

We need to change the ownership of new Jenkins binary using following command

sudo chown root:root jenkins.war 

Step 6: Start The Jenkins Server

Now it’s time to start the Jenkins server using the following command

sudo systemctl start jenkins      //For SystemD Based Linux 
OR 
sudo service jenkins start        //For Init Based Linux

Step 7: Check The Jenkins Version

We need to check the Jenkins version using the following command

cat /var/lib/jenkins/config.xml | grep '<version>' 

Congratulations! You successfully upgrade the Jenkins.