Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins - add JDK 11 to JDK list

I need to build my application using Java 11.
However the dropdown menu stops at Java 9.

What do I do? OpenJDK is acceptable too.
I'm on the latest version of Jenkins.

Edit: as of now I've downloaded the binaries using wget, extracted them on the machine, and added a JDK JDK_HOME entry via Global Configurations.

like image 763
LppEdd Avatar asked Mar 19 '19 14:03

LppEdd


People also ask

Does Jenkins support Java 11?

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.

Can we configure multiple versions of Java JDK in Jenkins?

Within Jenkins you can configure multiple different JDKs for you individual job builds. They're configured under the 'Manage Jenkins' -> 'Configure System' page, in the 'JDK' section. Just install each different JDK on a different place in your filesystem, point Jenkins to it and then given it a name on this page.

How do I install Java 11 JDK?

To run the JDK installer: Start the JDK 11 installer by double-clicking the installer's icon or file name in the download location. Follow the instructions provided by the installer. After the installation is complete, delete the downloaded file to recover the disk space.

How do I set Java version in Jenkins?

On the Jenkins Main Page, to the Left click "Manage Jenkins." Access "Global Tool Configuration" menu, and under this menu there is a location about half way down that should say "JDK Installations." Click that button and it will open a new menu where you can add an alternate JDK.


2 Answers

I guess you are using the JDK Tool Plugin.

Click "Manage Jenkins" > "Global Tool Configuration" > "Add JDK" (near JDK installations)

Delete the java.sun.com installer. Just click "Add Installer" below and choose "Extract .zip/.tar.gz"

Enter following:

Label: openjdk-11

Download URL: https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz

Subdirectory of extracted archive: jdk-11.0.1 (Optional subdirectory of the downloaded and unpacked archive to use as the tool's home directory.)

And "Save" the configuration

=> Use JDK label (openjdk-11) in your build job.


The download-link given above appears to be from a time when java 11 hadn't entered LTS;

Instead go to Java Platform, Standard Edition 11 Reference Implementations which will provide you the download-link to the most recent release of the...

[...] official Reference Implementation for Java SE 11 (JSR 384) [...] based solely upon open-source code available from the JDK 11 Project in the OpenJDK Community. This Reference Implementation applies to both the Final Release of JSR 384 (Sep 2018) and Maintenance Release 1 (Mar 2019).

... which as of this writing is: https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz

like image 61
kasul Avatar answered Oct 06 '22 02:10

kasul


JDKs can be managed with JDK Tool Plugin which usually comes pre-installed.

  • Go to "Manage Jenkins" > "Global Tool Configuration"

  • Under JDK installations click 'Add JDK'

  • Delete the default installer and add an installer of type "Extract .zip/.tar.gz"

  • Find a URL to a JDK archive in tar.gz or zip format.

OpenJDK 11 binary can be found in jdk.java.net/java-se-ri/11

This is the setting I have for openjdk-11+28

JDK name: OpenJDK-11
Label: (Keep this blank)
Download URL for binary archive: https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz

Subdirectory of extracted archive: jdk-11

Here in my case openjdk-11+28_linux-x64_bin.tar.gz, did contain a subdirectory named jdk-11

If it's incorrectly set up you might see the error:

Error: JAVA_HOME is not defined correctly.
  We cannot execute /var/jenkins_home/tools/hudson.model.JDK/JDK-11/bin/java
like image 37
Gayan Weerakutti Avatar answered Oct 06 '22 03:10

Gayan Weerakutti