Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-10191

JDK selection is hidden even when a JDK is configured

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • core
    • None

      "default" JDK is the one present in user PATH - let's say JDK6
      if I want to use an alternative JDK5, I declare it on system configuration
      But I still can't edit my project configuration to select JDK and it still run with JDK6
      I need to declare a 2nd JDK so that the select box appears and I can configure my JDK5 build.

      I suggest to deprecate support for "Default" JDK, as this is confusing and dependent on host system configuration.

      To ensure backward compatibility, jenkins could detect at startup jobs that don't have a <JDK> element in config and automatically create a "System" JDK in global configuration based on System.getProperty('java.home').

          [JENKINS-10191] JDK selection is hidden even when a JDK is configured

          Daniel Beck added a comment -

          Andreas: Please provide relevant config.xml from the affected jobs at the relevant points in time (as that will contain the JDK configuration even if hidden from UI). Your second job's issue does not appear to be possible if one JDK is configured system-wide.

          Daniel Beck added a comment - Andreas: Please provide relevant config.xml from the affected jobs at the relevant points in time (as that will contain the JDK configuration even if hidden from UI). Your second job's issue does not appear to be possible if one JDK is configured system-wide.

          Andreas Horst added a comment -

          And ambiguity strikes again: 1.7.0_u55 was the OS wide JDK on the slave node while 1.7.0_u65 was the Jenkins "system-wide" configured JDK. Since the job did not specify anything related to a JDK (you cannot select a JDK in a Maven job unless Jenkins has more than one JDK installation) the job used the OS JDK (which IMHO is wrong). It should never fall back to the environment since nobody can guarantee even the existence of a JDK for arbitrary environments.

          I'll come back with the configuration files in a minute (I'll have to remove the second JDK installation in order to reproduce the original behavior).

          Andreas Horst added a comment - And ambiguity strikes again: 1.7.0_u55 was the OS wide JDK on the slave node while 1.7.0_u65 was the Jenkins "system-wide" configured JDK. Since the job did not specify anything related to a JDK (you cannot select a JDK in a Maven job unless Jenkins has more than one JDK installation) the job used the OS JDK (which IMHO is wrong). It should never fall back to the environment since nobody can guarantee even the existence of a JDK for arbitrary environments. I'll come back with the configuration files in a minute (I'll have to remove the second JDK installation in order to reproduce the original behavior).

          Andreas Horst added a comment -

          config.no.jdk.xml is a job configuration where only one JDK installation is known to Jenkins (hence no actual value). config.with.jdk.xml is a configuration of the same job but this time an actual JDK (one of two JDKs known to Jenkins) is selected.

          Andreas Horst added a comment - config.no.jdk.xml is a job configuration where only one JDK installation is known to Jenkins (hence no actual value). config.with.jdk.xml is a configuration of the same job but this time an actual JDK (one of two JDKs known to Jenkins) is selected.

          Andreas Horst added a comment -

          These are excerpts from some build console outputs.
          With config.no.jdk.xml:

          Started by user Andreas Horst
          Building remotely on lab76 (maven java) in workspace /home/jenkins/workspace/Vire
          Updating https://sselab.de/lab9/private/svn/vire/trunk/vire at revision '2014-07-21T16:52:50.204 +0200'
          At revision 156
          no change for https://sselab.de/lab9/private/svn/vire/trunk/vire since the previous build
          Parsing POMs
          maven31-agent.jar already up to date
          maven31-interceptor.jar already up to date
          maven3-interceptor-commons.jar already up to date
          [Vire] $ java -XX:MaxPermSize=512m -Djava.awt.headless=true -cp /home/jenkins/maven31-agent.jar:/home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1/boot/plexus-classworlds-2.5.1.jar:/home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1/conf/logging jenkins.maven3.agent.Maven31Main /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1 /home/jenkins/slave.jar /home/jenkins/maven31-interceptor.jar /home/jenkins/maven3-interceptor-commons.jar 60423
          <===[JENKINS REMOTING CAPACITY]===>channel started
          Executing Maven:  -B -f /home/jenkins/workspace/Vire/pom.xml -s /home/jenkins/.m2/settings.vire.xml clean install -e -X
          Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T18:37:52+01:00)
          Maven home: /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1
          Java version: 1.7.0_55, vendor: Oracle Corporation
          Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
          Default locale: en_US, platform encoding: UTF-8
          OS name: "linux", version: "3.13.0-32-generic", arch: "amd64", family: "unix"
          [INFO] Error stacktraces are turned on.
          [DEBUG] Reading global settings from /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1/conf/settings.xml
          [DEBUG] Reading user settings from /home/jenkins/.m2/settings.vire.xml
          [INFO] Scanning for projects...
          

          With config.with.jdk.xml:

          Started by user Andreas Horst
          Building remotely on lab76 (maven java) in workspace /home/jenkins/workspace/Vire
          Updating https://sselab.de/lab9/private/svn/vire/trunk/vire at revision '2014-07-21T17:14:44.362 +0200'
          At revision 156
          no change for https://sselab.de/lab9/private/svn/vire/trunk/vire since the previous build
          Parsing POMs
          maven31-agent.jar already up to date
          maven31-interceptor.jar already up to date
          maven3-interceptor-commons.jar already up to date
          [Vire] $ /home/jenkins/tools/hudson.model.JDK/Java_SE_Development_Kit_7u65/bin/java -XX:MaxPermSize=512m -Djava.awt.headless=true -cp /home/jenkins/maven31-agent.jar:/home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1/boot/plexus-classworlds-2.5.1.jar:/home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1/conf/logging jenkins.maven3.agent.Maven31Main /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1 /home/jenkins/slave.jar /home/jenkins/maven31-interceptor.jar /home/jenkins/maven3-interceptor-commons.jar 43246
          <===[JENKINS REMOTING CAPACITY]===>channel started
          Executing Maven:  -B -f /home/jenkins/workspace/Vire/pom.xml -s /home/jenkins/.m2/settings.vire.xml clean install -e -X
          Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T18:37:52+01:00)
          Maven home: /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1
          Java version: 1.7.0_65, vendor: Oracle Corporation
          Java home: /home/jenkins/tools/hudson.model.JDK/Java_SE_Development_Kit_7u65/jre
          Default locale: en_US, platform encoding: UTF-8
          OS name: "linux", version: "3.13.0-32-generic", arch: "amd64", family: "unix"
          [INFO] Error stacktraces are turned on.
          [DEBUG] Reading global settings from /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1/conf/settings.xml
          [DEBUG] Reading user settings from /home/jenkins/.m2/settings.vire.xml
          [INFO] Scanning for projects...
          

          As you can see, the first build is IMHO run with the wrong JDK since the default JDK there is the OS JDK and NOT the single JDK known to Jenkins (which was 1.7.0_u65). Only after selecting the right JDK in the job configuration (which required adding a second JDK installation) the build was executed with the right JDK (second console output).

          Andreas Horst added a comment - These are excerpts from some build console outputs. With config.no.jdk.xml: Started by user Andreas Horst Building remotely on lab76 (maven java) in workspace /home/jenkins/workspace/Vire Updating https://sselab.de/lab9/private/svn/vire/trunk/vire at revision '2014-07-21T16:52:50.204 +0200' At revision 156 no change for https://sselab.de/lab9/private/svn/vire/trunk/vire since the previous build Parsing POMs maven31-agent.jar already up to date maven31-interceptor.jar already up to date maven3-interceptor-commons.jar already up to date [Vire] $ java -XX:MaxPermSize=512m -Djava.awt.headless=true -cp /home/jenkins/maven31-agent.jar:/home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1/boot/plexus-classworlds-2.5.1.jar:/home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1/conf/logging jenkins.maven3.agent.Maven31Main /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1 /home/jenkins/slave.jar /home/jenkins/maven31-interceptor.jar /home/jenkins/maven3-interceptor-commons.jar 60423 <===[JENKINS REMOTING CAPACITY]===>channel started Executing Maven: -B -f /home/jenkins/workspace/Vire/pom.xml -s /home/jenkins/.m2/settings.vire.xml clean install -e -X Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T18:37:52+01:00) Maven home: /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1 Java version: 1.7.0_55, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.13.0-32-generic", arch: "amd64", family: "unix" [INFO] Error stacktraces are turned on. [DEBUG] Reading global settings from /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1/conf/settings.xml [DEBUG] Reading user settings from /home/jenkins/.m2/settings.vire.xml [INFO] Scanning for projects... With config.with.jdk.xml: Started by user Andreas Horst Building remotely on lab76 (maven java) in workspace /home/jenkins/workspace/Vire Updating https://sselab.de/lab9/private/svn/vire/trunk/vire at revision '2014-07-21T17:14:44.362 +0200' At revision 156 no change for https://sselab.de/lab9/private/svn/vire/trunk/vire since the previous build Parsing POMs maven31-agent.jar already up to date maven31-interceptor.jar already up to date maven3-interceptor-commons.jar already up to date [Vire] $ /home/jenkins/tools/hudson.model.JDK/Java_SE_Development_Kit_7u65/bin/java -XX:MaxPermSize=512m -Djava.awt.headless=true -cp /home/jenkins/maven31-agent.jar:/home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1/boot/plexus-classworlds-2.5.1.jar:/home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1/conf/logging jenkins.maven3.agent.Maven31Main /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1 /home/jenkins/slave.jar /home/jenkins/maven31-interceptor.jar /home/jenkins/maven3-interceptor-commons.jar 43246 <===[JENKINS REMOTING CAPACITY]===>channel started Executing Maven: -B -f /home/jenkins/workspace/Vire/pom.xml -s /home/jenkins/.m2/settings.vire.xml clean install -e -X Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T18:37:52+01:00) Maven home: /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1 Java version: 1.7.0_65, vendor: Oracle Corporation Java home: /home/jenkins/tools/hudson.model.JDK/Java_SE_Development_Kit_7u65/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.13.0-32-generic", arch: "amd64", family: "unix" [INFO] Error stacktraces are turned on. [DEBUG] Reading global settings from /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.2.1/conf/settings.xml [DEBUG] Reading user settings from /home/jenkins/.m2/settings.vire.xml [INFO] Scanning for projects... As you can see, the first build is IMHO run with the wrong JDK since the default JDK there is the OS JDK and NOT the single JDK known to Jenkins (which was 1.7.0_u65). Only after selecting the right JDK in the job configuration (which required adding a second JDK installation) the build was executed with the right JDK (second console output).

          Andreas Horst added a comment -

          As a side note: I can no longer reproduce the Sonar issue since apparently the value of the <jdk> element in the job configuration differs between a fresh Jenkins installation with only one JDK installation and a Jenkins which had two JDK installations of which one was removed later on.

          Andreas Horst added a comment - As a side note: I can no longer reproduce the Sonar issue since apparently the value of the <jdk> element in the job configuration differs between a fresh Jenkins installation with only one JDK installation and a Jenkins which had two JDK installations of which one was removed later on.

          Robert Dahlström added a comment - - edited

          Just ran into this as well and a bit of googling led me here. However, my wants are slightly different: I'd also like an option to tell Jenkins to explicitly use the System provided JDK. Mainly because the Jenkins I currently maintain should use the same JDK/JRE we have in production and we maintain the JDK/JRE with puppet, outside of the Jenkins eco-system.

          I do agree that the current way to work with JDK's in Jenkins is a bit confusing and it does not tie all plugins together (maven job with sonar's 'inherit from job' when the job's JDK is 'Default' is one such example).

          Robert Dahlström added a comment - - edited Just ran into this as well and a bit of googling led me here. However, my wants are slightly different: I'd also like an option to tell Jenkins to explicitly use the System provided JDK. Mainly because the Jenkins I currently maintain should use the same JDK/JRE we have in production and we maintain the JDK/JRE with puppet, outside of the Jenkins eco-system. I do agree that the current way to work with JDK's in Jenkins is a bit confusing and it does not tie all plugins together (maven job with sonar's 'inherit from job' when the job's JDK is 'Default' is one such example).

          S added a comment -

          I can confirm this is still present in v2.19.

          I noticed sometime after 2.17 that all of my JDK tool installations were gone, and that the UI selection for the JDK for all maven jobs was no longer visible, but was still set in the config.xml.

          S added a comment - I can confirm this is still present in v2.19. I noticed sometime after 2.17 that all of my JDK tool installations were gone, and that the UI selection for the JDK for all maven jobs was no longer visible, but was still set in the config.xml.

          Daniel Beck added a comment -

          of my JDK tool installations were gone, and that the UI selection for the JDK for all maven jobs was no longer visible

          Moved to /configureTools

          Daniel Beck added a comment - of my JDK tool installations were gone, and that the UI selection for the JDK for all maven jobs was no longer visible Moved to /configureTools

          S added a comment -

          Correct, however I am confirming that the JDK selection from a maven job is not visible even though it is specified in the job's configuration. That was a side-effect I noticed at the same time (may or may not be related).

          S added a comment - Correct, however I am confirming that the JDK selection from a maven job is not visible even though it is specified in the job's configuration. That was a side-effect I noticed at the same time (may or may not be related).

          Daniel Beck added a comment -

          How many JDKs are configured globally?

          Daniel Beck added a comment - How many JDKs are configured globally?

            Unassigned Unassigned
            ndeloof Nicolas De Loof
            Votes:
            11 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated: