Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the JDK for a Jenkins job?

Tags:

java

jenkins

enter image description hereI have imported the jenkins jobs from existing jenkins server from another machine. But the problem is, it has the JDK referenced as per the old machines and I want to change it to use the JDK configured in my new jenkins. But I am unable to find any way of doing this. So, please if you have come across this situation and found a way then please help me too.

Thanks.

like image 764
GuruKulki Avatar asked Mar 02 '15 13:03

GuruKulki


People also ask

How do I select 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.

Where is Jenkins JDK setup?

You can add a JDK version by navigating to Jenkins -> Manage Jenkins -> Global Tool Configuration. The global tool configuration menu will open the following window: Next, click the JDK Installations” button under the JDK section to configure multiple JDK versions.

Which JDK is compatible with Jenkins?

Jenkins project performs a full test flow with the following JDK/JREs: OpenJDK JDK / JRE 11 - 64 bits. OpenJDK JDK / JRE 17 - 64 bits.

Can we configure multiple versions of Java JDK in Jenkins?

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 with the controller running Java 11. There are many users that run multiple JDK versions with Jenkins jobs. It works very well.


2 Answers

There is a JDK dropdown in "job name" -> Configure in Jenkins web ui. It will list all JDKs available in Jenkins configuration.

like image 130
nomis Avatar answered Sep 16 '22 12:09

nomis


For existing jobs you're editing, the JDK drop-down choice may not be available if you've just added a single JDK config in the 'Configure System' Jenkins settings.

However, it is available for new jobs.

Surprisingly, if you add a second JDK config, it becomes available in an existing job too.

This looks to me like a bug (tested in Jenkins ver. 1.629).

See a similar issue raised here: JDK selection is hidden even when a JDK is configured

like image 41
RZet Avatar answered Sep 18 '22 12:09

RZet