Overview
Beginning with Jenkins 2.357 (released on June 28, 2022) and the forthcoming 2.361.1 LTS release, Jenkins requires Java 11 or newer. Additionally, beginning with Jenkins 2.355 (released on June 14, 2022) and Jenkins 2.346.1 LTS (released on June 22, 2022), Jenkins supports Java 17. Plugins have already been prepared in JENKINS-68446. Use the Plugin Manager to upgrade all plugins before and after upgrading to Jenkins 2.357.
OS packages
Users of the official Jenkins OS packages for Debian, Red Hat, and SUSE Linux distributions should note that these packages are agnostic to the Java vendor. In other words, you must bring your own Java package. One straightforward way to do this is to install Java 11 from your Linux distribution, as described on the package download site:
Debian
apt-get install fontconfig openjdk-11-jre
Red Hat
yum install fontconfig java-11-openjdk
openSUSE
zypper install dejavu-fonts fontconfig java-11-openjdk
By virtue of not requiring any custom repositories, this is certainly the simplest method (and the one used by the Jenkins project’s packaging tests), but it does not give the user a high degree of control over the Java runtime environment. As mentioned previously, the official Jenkins Docker images use Adoptium/Eclipse Temurin (as does the Jenkins infrastructure project). Enthusiastic users may wish to install Java from Adoptium or another vendor. Adoptium recently began providing Linux installation packages, as described in a piece by George Adams. Ultimately, the choice of which Java vendor to use is your own, as long as that vendor provides Java 11 or Java 17. Refer to your chosen Java vendor for installation instructions.
Once you have installed a suitable version of Java, configure Jenkins to use that Java runtime. The most straightforward way is to configure that version of Java as the default version of Java at the operating system (OS) level:
Debian
update-alternatives --config java
Red Hat
alternatives --config java
openSUSE
update-alternatives --config java
Alternatively, users who do not wish to change the default version of Java can customize the JAVA_HOME or JENKINS_JAVA_CMD environment variable as part of the Jenkins systemd(1) service unit. Refer to the Managing systemd services section of the Jenkins documentation for more information.
Release jenkins
We could upgrade jenkins with the forthcoming 2.361.1 LTS release, https://updates.jenkins.io/download/war/2.361.1/jenkins.war
- The first, we should backup old jenkins.war at directory
/usr/share/java/jenkins.war
to/usr/share/java/jenkins.war-yymmdd
mv /usr/share/java/jenkins.war /usr/share/java/jenkins.war-$(date +%y%m%d)
- After, we download latest release and replace old jenkins.war
curl https://updates.jenkins.io/download/war/2.361.1/jenkins.war -o /usr/share/java/jenkins.war
- Final, we restart jenkins service
sudo service jenkins restart
- In order to check the upgrade was successful or not, we go to about jenkins at link
https://your-jenkins-server/about/
. Near jenkins icon, it shows jenkins’s version.
Upgrading Plugins
It’s important not just to upgrade Jenkins and the JVM, but also to upgrade the plugins which support Java 11. Plugin upgrades assure compatibility with the most recent Jenkins releases.