# Jenkins Upgrade and using 2 different Java versions

**URL:** <https://community.jenkins.io/t/jenkins-upgrade-and-using-2-different-java-versions/1571>\
**Category:** Ask a question\
**Tags:** java\
**Created:** [February 17, 2022, 2:36pm UTC](https://community.jenkins.io/t/jenkins-upgrade-and-using-2-different-java-versions/1571 "2022-02-17T14:36:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@Marco](https://community.jenkins.io/u/Marco)\
**Post date:** [February 17, 2022, 2:36pm UTC](https://community.jenkins.io/t/jenkins-upgrade-and-using-2-different-java-versions/1571/1 "2022-02-17T14:36:02Z")

</div>

Hi all

I need to upgrade our Jenkins-Docker-Container from version 2.153 to 2.335.  
At the moment our java-pipelines are using Java-8 and we wanna upgrade our java-pipelines to Java-11, thats the reason why I want to upgrade the whole jenkins (“2.335-jdk11” docker-tag).

But with the new Jenkins (2.335-jdk11), I also want to have Java-8 installed.  
I know there is the possibility to have multiple JDK in Jenkins:

- [Making jenkins and maven use different java versions - Stack Overflow](https://stackoverflow.com/questions/41401055/making-jenkins-and-maven-use-different-java-versions#:~:text=Within%20Jenkins%20you%20can%20configure,a%20name%20on%20this%20page)

- [java - How to change the JDK for a Jenkins job? - Stack Overflow](https://stackoverflow.com/questions/28810477/how-to-change-the-jdk-for-a-jenkins-job)

My questions are:

1. Do you’ve any tips/hints for the Jenkins-Docker-Container-Upgrade from 2.153 to 2.335?
2. There will be no lost of existing pipelines, it’s fully compatible?
3. If I’m installing the Java-8 and reboot the container, I think Java-8 is then gone/away (because it’s not installed in a docker-volume)? How can I install Java-8 in the new Jenkins-Docker-Container to have it reboot-persistent?

Many thanks for your feedback!

Best regards,  
Marco

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [February 17, 2022, 7:15pm UTC](https://community.jenkins.io/t/jenkins-upgrade-and-using-2-different-java-versions/1571/2 "2022-02-17T19:15:57Z")

</div>

> [@Marco](#):
>
> I need to upgrade our Jenkins-Docker-Container from version 2.153 to 2.335.  
> At the moment our java-pipelines are using Java-8 and we wanna upgrade our java-pipelines to Java-11, thats the reason why I want to upgrade the whole jenkins (“2.335-jdk11” docker-tag).

That’s proposing an upgrade from a weekly that was [released over 3 years ago](https://www.jenkins.io/changelog-old/#v2.153) to the most recent weekly. Since your upgrade pattern seems to be infrequent, you should consider a switch from [weekly release line](https://www.jenkins.io/download/weekly/) to the [long term support release line](https://www.jenkins.io/download/lts/) as part of this upgrade. Current long term support release is 2.319.3.

In order to make the upgrade in smaller steps, you could upgrade to 2.319.3 running Java 8. The Java 8 container image is `jenkins/jenkins:2.319.3-jdk8`. Ultimately, you will switch to `jenkins/jenkins:2.319.3` for Java 11, but you can make the transition from Java 8 to Java 11 as a step that is separate from the transition from 2.153 to 2.319.3.

> [@Marco](#):
>
> But with the new Jenkins (2.335-jdk11), I also want to have Java-8 installed.

Don’t install Java 8 in the container used for the Jenkins controller. Run your jobs on an agent and have Java 8 (or other tools) installed on that agent instead of installing them on the controller.

The Jenkins documentation explains the details why that is the preferred approach.

> **[Controller Isolation](https://www.jenkins.io/doc/book/security/controller-isolation/#not-building-on-the-built-in-node)**
>
> Jenkins – an open source automation server which enables developers around the world to reliably build, test, and deploy their software

There are also videos that describe the purposes of Jenkins agents, like

[![](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/6/6cb6d5f297841b64eb45b9d61d115253c9e53a0a.jpeg "What Is a Jenkins Agent?") ](https://www.youtube.com/watch?v=4KghHJEz5no)

> [@Marco](#):
>
> My questions are:
> 
> 1. Do you’ve any tips/hints for the Jenkins-Docker-Container-Upgrade from 2.153 to 2.335?

Create a new container that is based on the `jenkins/jenkins:2.319.3` container image but includes the plugins you use, managed as code with a `plugins.txt` file. You can use that container image to experiment with the upgrade without breaking your existing installation.

If you’re interested to see how others have done it, there are public repositories available that illustrate it. My [lts-with-plugins branch](https://github.com/MarkEWaite/docker-lfs/tree/lts-with-plugins) is one example. There are others, I’m sure.

> [@Marco](#):
>
> 1. There will be no lost of existing pipelines, it’s fully compatible?

There were major Jenkins upgrades across the time that you’re considering. Your most reliable path would be to review the [LTS upgrade guides](https://www.jenkins.io/doc/upgrade-guide/) for each of the LTS versions between 2.153 and your destination version. Some of the most common areas of difficulty include the configuration form modernization that was released in 2.277.1 LTS and is described in this blog post

> **[Jenkins 2.264+: Major changes in the weekly release line](https://www.jenkins.io/blog/2020/11/10/major-changes-in-weekly-releases/)**
>
> Latest Jenkins weekly releases contain large changes. We invite Jenkins users to evaluate these changes and provide their feedback

The detailed steps for the configuration form modernization upgrade are also described in

> [@Migrating Jenkins](https://community.jenkins.io/t/migrating-jenkins/894/5):
>
> Usually if a form fails to save with Jenkins 2.277.1 or later, it is due to an outdated plugin that needs to be updated or removed. Jenkins 2.277.1 modernized configuration form handling by converting the HTML table based alignment to use div based alignment. You can read more about it in the blog post: The [Jenkins 2.277.1 changelog](https://www.jenkins.io/changelog-stable/#v2.277.1) provides additional information. The [Jenkins 2.277.1 upgrade guide](https://www.jenkins.io/doc/upgrade-guide/2.277/#upgrading-to-jenkins-lts-2-277-1) identifies the steps that need to be performed. Those steps include: Update all plugins …

---

<div class="post-metadata">

**Author:** ![Marco](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@Marco](https://community.jenkins.io/u/Marco)\
**Post date:** [February 18, 2022, 8:14am UTC](https://community.jenkins.io/t/jenkins-upgrade-and-using-2-different-java-versions/1571/3 "2022-02-18T08:14:33Z")

</div>

Hi Mark

Many thanks for your feedback.

Okay, so that means for the first upgrade step I will use the official docker-tag “jenkins/jenkins:2.319.3-lts”. And then for the second upgrade step I will use the official docker-tag “jenkins/jenkins:2.319.3-lts-jdk11”.  
Is it right? But why I need to do the JDK-11 Upgrade separatly, you did not explained the reason, what is the benefit of it? It is possible directly go to “jenkins/jenkins:2.319.3-lts-jdk11”?

Regarding the Jenkins-Agent, this is overheaded for us, because we need this JDK-8 only temporary until all our Jenkins-Pipeline are able to use JDK-11. In time we speak about one month or so, after that everything should running on JDK-11 and we don’t need JDK-8 anymore.  
The following procedure is still possible with the “jenkins/jenkins:2.319.3-lts-jdk11”, right?

→ [Making jenkins and maven use different java versions - Stack Overflow](https://stackoverflow.com/questions/41401055/making-jenkins-and-maven-use-different-java-versions#:~:text=Within%20Jenkins%20you%20can%20configure,a%20name%20on%20this%20page)

→ [java - How to change the JDK for a Jenkins job? - Stack Overflow](https://stackoverflow.com/questions/28810477/how-to-change-the-jdk-for-a-jenkins-job).

So for my preparation I need to read about the “LTS upgrade guides”.

Regards,  
Marco

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [February 18, 2022, 1:16pm UTC](https://community.jenkins.io/t/jenkins-upgrade-and-using-2-different-java-versions/1571/4 "2022-02-18T13:16:39Z")

</div>

> [@Marco](#):
>
> Okay, so that means for the first upgrade step I will use the official docker-tag “jenkins/jenkins:2.319.3-lts”. And then for the second upgrade step I will use the official docker-tag “jenkins/jenkins:2.319.3-lts-jdk11”.  
> Is it right?

Almost. If you want to stay on JDK 8 in order to reduce the size of each step of the upgrade, then you would use `jenkins/jenkins:2.319.3-jdk8` as the Docker container for the first step. After that first step of the upgrade is complete, you would upgrade to Java 11 by using the `jenkins/jenkins:2.319.3` container or its more precisely labeled alias `jenkins/jenkins:2.319.3-jdk11`.

> [@Marco](#):
>
> It is possible directly go to “jenkins/jenkins:2.319.3-lts-jdk11”?

Yes, if you don’t mind making a larger upgrade step, then you can go directly to JDK 11.

> [@Marco](#):
>
> Regarding the Jenkins-Agent, this is overheaded for us, because we need this JDK-8 only temporary until all our Jenkins-Pipeline are able to use JDK-11. In time we speak about one month or so, after that everything should running on JDK-11 and we don’t need JDK-8 anymore.

Even if you don’t need JDK 8 any longer, you should prefer to have no executors on the controller and configure agents to execute the jobs. See the article on controller isolation for the list of reasons

> **[Controller Isolation](https://www.jenkins.io/doc/book/security/controller-isolation/#not-building-on-the-built-in-node)**
>
> Jenkins – an open source automation server which enables developers around the world to reliably build, test, and deploy their software

> [@Marco](#):
>
> The following procedure is still possible with the “jenkins/jenkins:2.319.3-lts-jdk11”, right?
> 
> → [Making jenkins and maven use different java versions - Stack Overflow](https://stackoverflow.com/questions/41401055/making-jenkins-and-maven-use-different-java-versions#:~:text=Within%20Jenkins%20you%20can%20configure,a%20name%20on%20this%20page)
> 
> → [java - How to change the JDK for a Jenkins job? - Stack Overflow](https://stackoverflow.com/questions/28810477/how-to-change-the-jdk-for-a-jenkins-job).

Yes, Jenkins allows builds to run with many different JDK versions. We use Java 8, Java 11, and Java 17 regularly on [ci.jenkins.io](https://ci.jenkins.io/) with the controller running Java 11. There are many users that run multiple JDK versions with Jenkins jobs. It works very well.

This video includes an example that configures an Apache Maven tool to use a different JDK

[![](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/6/62e9c3af55b8ae3ee2a067939731409156e028db.jpeg "How to Configure Maven in Jenkins") ](https://www.youtube.com/watch?v=V-VFrYF_Z1Y&t=624s)

---

<div class="post-metadata">

**Author:** ![Sameeksha](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@Sameeksha](https://community.jenkins.io/u/Sameeksha)\
**Post date:** [February 23, 2022, 10:25am UTC](https://community.jenkins.io/t/jenkins-upgrade-and-using-2-different-java-versions/1571/5 "2022-02-23T10:25:28Z")

</div>

Hi Mark,  
I have one query  
The latest jenkins version 2.319.3 is compatible with java 8 ?

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [February 23, 2022, 3:14pm UTC](https://community.jenkins.io/t/jenkins-upgrade-and-using-2-different-java-versions/1571/6 "2022-02-23T15:14:44Z")

</div>

> [@Sameeksha](#):
>
> The latest jenkins version 2.319.3 is compatible with java 8 ?

Yes. Java 8 and Java 11 are both supported by Jenkins 2.319.3. Java 8 and Java 11 Docker images are also provided for Jenkins 2.319.3.

[https://www.jenkins.io/doc/administration/requirements/java/](https://www.jenkins.io/doc/administration/requirements/java/)
