Save your legacy Jenkins when upgrading


Image by

Recently, I've been working on helping the team refactor the old legacy Jenkins and smoother the CI/CD flows. It's been almost 2 years since its last upgrade. It's terrifying but we have to fix it.

I left some notes and tips here if someday I need this remarkable memory. (It's been a long time since I last fixed the Jenkins.)

To save your Jenkins, you MUST follow the steps as following. Otherwise, you need a big heart and having the attitude that are not afraid of being shocked if all jobs are gone. (Not only the Jenkins Jobs but also ...)

  1. Note the origin Jenkins version. For example, 2.263.1
  2. Find and note the WAR file path. For example, /usr/share/jenkins/jenkins.war
  3. The Jenkins home path. For example, /var/jenkins_home
  4. Copy the whole Jenkins home directory to another directory. For example, /opt/jenkins_home2 
  5. (Optional) Double check that you have another backup plugin like ThinBackup and where are those data?
If you finished at least step 1 to 4, then you are free to go to upgrade anything you like. Click and upgrade the missing patches you have been warned.

Warnings and Suggestions

And then, if you are the one who is in the same situation like the team. There are 80% or more possibility the legacy Jenkins will not be running anymore. Especially you have as more as plugins on your Jenkins.

There will be thousands of tons of dependancies you need to fix. Sometimes, some plugins are deprecated and you have no new versions to fix the issues. So, you need to remove them and find the replacements. It will be long journey and it's hard to finish without pains.

The common case you will get is: after upgrading, unfortunately, your Jenkins is no longer working anymore.

But we still can try recovering it by the following steps, 

NOTE: The example is using Docker but same concept if you didn't install your Jenkins on it.
  1. Go to Jenkins' official website and download the origin version. For example, 2.263.1.
  2. Mount/replace the war to the new one. For example: docker run -d -it -v /opt/jenkins.war.2.263.1:/usr/share/jenkins/jenkins.war
  3. Mount/replace the Jenkins home with the old one. For example: docker run -d -it -v /opt/jenkins_home2:/var/jenkins_home
  4. Run it again.
If you are lucky enough, your Jenkins should be back to normal (but the legacy one) again.