• Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • core, m2release-plugin
    • None
    • Issue encountered on "cloudbees"

      For some reasons, I need to compile my code with JDK 1.5. I configured a Hudson job with this version and I also configured the maven enforcer plugin to check if the proper JDK is used.

      When I do a release I get this error, obviously I don't use during release the JDK configured for the job :

      FO] [INFO] [enforcer:enforce

      {execution: enforce-versions}

      ]
      [INFO] [DEBUG] Executing rule: org.apache.maven.plugins.enforcer.RequireJavaVersion
      [INFO] [DEBUG] Rule org.apache.maven.plugins.enforcer.RequireJavaVersion is cacheable.
      [INFO] [DEBUG] Detected Java String: 1.6.0_20
      [INFO] [DEBUG] Normalized Java String: 1.6.0-20
      [INFO] [DEBUG] Parsed Version: Major: 1 Minor: 6 Incremental: 0 Build: 20 Qualifier: null
      [INFO] [INFO] ------------------------------------------------------------------------
      [INFO] [ERROR] BUILD ERROR
      [INFO] [INFO] ------------------------------------------------------------------------
      [INFO] [INFO] org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message:
      [INFO] Detected JDK Version: 1.6.0-20 is not in the allowed range [1.5,1.6).
      [INFO]
      [INFO] [INFO] ------------------------------------------------------------------------
      [INFO] [DEBUG] Trace
      [INFO] org.apache.maven.lifecycle.LifecycleExecutionException: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message:
      [INFO] Detected JDK Version: 1.6.0-20 is not in the allowed range [1.5,1.6).

          [JENKINS-7886] Use the JDK configured for the job

          James Nord added a comment -

          Can you attach a dump of the node environment?

          JAVA_HOME should be set correctly.

          James Nord added a comment - Can you attach a dump of the node environment? JAVA_HOME should be set correctly.

          vivekp added a comment -

          Looks like m2release plugin does let override JAVA_HOME setting over the project level JDK selection. Here is how I can reproduce it:

          I have JAVA_HOME to JDK6 setting under configure hudson screen. Then in my project I select JDK5.

          When the build happens, mvn release:prepare is invoked using JAVA_HOME rather than the JDK selected at the project level. This seems like a bug or clearly not as ones expectation would be. Basically project level JDK setting should override the JAVA_HOME setting anywhere else.

          Looking inside m2release plugin source code, M2ReleaseBuildWrapper:buildEnvVars() has this code commented out,

          /*
          if (!env.containsKey("JAVA_HOME"))

          { env.put("JAVA_HOME", mmSet.getJDK().getHome()); }

          */

          Maybe this is not what the fix is. Someway it needs to indicate what JDK to use. I thin the project JDK can be obtained from Build inside setup() method. I have attached a mvn testcase to reproduce this issue. Simply create a maven2 job and point to the pom file, set JAVA_HOME at the global level as mentioned above.

          vivekp added a comment - Looks like m2release plugin does let override JAVA_HOME setting over the project level JDK selection. Here is how I can reproduce it: I have JAVA_HOME to JDK6 setting under configure hudson screen. Then in my project I select JDK5. When the build happens, mvn release:prepare is invoked using JAVA_HOME rather than the JDK selected at the project level. This seems like a bug or clearly not as ones expectation would be. Basically project level JDK setting should override the JAVA_HOME setting anywhere else. Looking inside m2release plugin source code, M2ReleaseBuildWrapper:buildEnvVars() has this code commented out, /* if (!env.containsKey("JAVA_HOME")) { env.put("JAVA_HOME", mmSet.getJDK().getHome()); } */ Maybe this is not what the fix is. Someway it needs to indicate what JDK to use. I thin the project JDK can be obtained from Build inside setup() method. I have attached a mvn testcase to reproduce this issue. Simply create a maven2 job and point to the pom file, set JAVA_HOME at the global level as mentioned above.

          vivekp added a comment -

          Testcase.

          vivekp added a comment - Testcase.

          James Nord added a comment -

          JAVA_HOME should be set by JDK.getEnvVars() so we should not anything special in the plugin (hence it is comented out).

          Indeed - this is working for me.

          When you say you have set "JAVA_HOME to JDK6 setting under configure hudson screen" can you explain what you have set?

          I will do some more digging but this may be a core bug in the way environment variables are not set correctly

          James Nord added a comment - JAVA_HOME should be set by JDK.getEnvVars() so we should not anything special in the plugin (hence it is comented out). Indeed - this is working for me. When you say you have set "JAVA_HOME to JDK6 setting under configure hudson screen" can you explain what you have set? I will do some more digging but this may be a core bug in the way environment variables are not set correctly

          In the picture attached, you can see a JDK 5 configured for the build (which is the JDK I want to use during the release also). But If I execute a release, then the JDK 6 (I suppose the platform's default) is used.

          Regards

          pascalleclercq added a comment - In the picture attached, you can see a JDK 5 configured for the build (which is the JDK I want to use during the release also). But If I execute a release, then the JDK 6 (I suppose the platform's default) is used. Regards

          James Nord added a comment -

          Something fishy..

          James Nord added a comment - Something fishy..

          James Nord added a comment -

          "When you say you have set "JAVA_HOME to JDK6 setting under configure hudson screen" can you explain what you have set?"

          Have you set this as a "Global Property" under http://yourjenkins/configure

          James Nord added a comment - "When you say you have set "JAVA_HOME to JDK6 setting under configure hudson screen" can you explain what you have set?" Have you set this as a "Global Property" under http://yourjenkins/configure

          James Nord added a comment -

          James Nord added a comment - see also http://jenkins.361315.n4.nabble.com/Can-Jenkins-set-JAVA-HOME-td3432884.html

          James Nord added a comment -

          I can not reproduce this on Windows or Linux.

          Without more information I will close the bug as can not reproduce.

          James Nord added a comment - I can not reproduce this on Windows or Linux. Without more information I will close the bug as can not reproduce.

          James Nord added a comment -

          If this is still happening please ask cloudbees to contact me so I can get access to debug this.

          James Nord added a comment - If this is still happening please ask cloudbees to contact me so I can get access to debug this.

          I have configured a project to use 32 bits JDK and default for all other project is 64 bits JDK. I also use two build nodes to build my projects. It works fine do a regular build, but once I do a "Perform Maven Release" jenkins select the default 64 bits JDK instead of the configured 32 bits, which is configured in jenkins-slave.xml

          Jenkins: 1.447.1
          Jenkins Maven Release Plug-in Plug-in: 0.9.1

          Christer Wikman added a comment - I have configured a project to use 32 bits JDK and default for all other project is 64 bits JDK. I also use two build nodes to build my projects. It works fine do a regular build, but once I do a "Perform Maven Release" jenkins select the default 64 bits JDK instead of the configured 32 bits, which is configured in jenkins-slave.xml Jenkins: 1.447.1 Jenkins Maven Release Plug-in Plug-in: 0.9.1

          James Nord added a comment -

          The JDK is picked up from the job configuration not the slave.

          If you are just using "default" JDK and have not configured jenkins with multiple JDKs (but just setting env vars in the slave config) then this is not supported - and anything that runs will likely use the platform JDK whenever Maven forks (this is not just the maven release plugin but potentially also surefire tests depending on how this is configured to run).

          see http://my.safaribooksonline.com/book/software-engineering-and-development/ide/9781449311155/configuring-your-jenkins-server/sect-configuration-jdks for details.

          If this is the case can you close the defect and update your config, otherwise can you supply more details please as I have been unable to reproduce this with multiple configured JDKs and Windows/Linux.

          James Nord added a comment - The JDK is picked up from the job configuration not the slave. If you are just using "default" JDK and have not configured jenkins with multiple JDKs (but just setting env vars in the slave config) then this is not supported - and anything that runs will likely use the platform JDK whenever Maven forks (this is not just the maven release plugin but potentially also surefire tests depending on how this is configured to run). see http://my.safaribooksonline.com/book/software-engineering-and-development/ide/9781449311155/configuring-your-jenkins-server/sect-configuration-jdks for details. If this is the case can you close the defect and update your config, otherwise can you supply more details please as I have been unable to reproduce this with multiple configured JDKs and Windows/Linux.

          Christer Wikman added a comment - - edited

          Nope, I have configured several JDKs and the job's configured JDK is not picked up for all goals when you click on "Maven Perfom Release". (But the configured JDK is correctly picked up from when you are click on "Build now"). I studied the log file from "Maven Perform Release" a bit more and it seems that the release goals are using the right JDK (1.6.0_35), but not the verify goal (JDK 1.6.0_30)

          "Maven Perform Release" log extract:
          Executing Maven: -B -f D:/jenkins/workspace/eps-uposadapter-main/product/eps/adapters/uposadapter/main/pom.xml -DdevelopmentVersion=1.0.1-SNAPSHOT -DreleaseVersion=1.0.0 -X -Dresume=false release:prepare release:perform
          Error stacktraces are turned on.
          Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01 0200)
          >>>Java version: 1.6.0_35
          >>>Java home: C:\java32\jdk1.6.0_35\jre (correct JDK as configured in job)
          Default locale: sv_SE, platform encoding: Cp1252
          OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"

          ...

          [DEBUG] Executing: cmd.exe /X /C "D:\jenkins\tools\maven221\bin\mvn.bat -B -X -D maven.repo.local=D:\Work\LocalRepository -P alwaysOn,codesign clean verify"
          [INFO] Error stacktraces are turned on.
          [INFO] Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01 0200)
          >>>[INFO] Java version: 1.6.0_30
          >>>[INFO] Java home: C:\Program Files\Java\jdk1.6.0_30\jre (Invalid JDK, should be c:\java32)
          [INFO] Default locale: sv_SE, platform encoding: Cp1252

          Christer Wikman added a comment - - edited Nope, I have configured several JDKs and the job's configured JDK is not picked up for all goals when you click on "Maven Perfom Release". (But the configured JDK is correctly picked up from when you are click on "Build now"). I studied the log file from "Maven Perform Release" a bit more and it seems that the release goals are using the right JDK (1.6.0_35), but not the verify goal (JDK 1.6.0_30) "Maven Perform Release" log extract: Executing Maven: -B -f D:/jenkins/workspace/eps-uposadapter-main/product/eps/adapters/uposadapter/main/pom.xml -DdevelopmentVersion=1.0.1-SNAPSHOT -DreleaseVersion=1.0.0 -X -Dresume=false release:prepare release:perform Error stacktraces are turned on. Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01 0200) >>>Java version: 1.6.0_35 >>>Java home: C:\java32\jdk1.6.0_35\jre (correct JDK as configured in job) Default locale: sv_SE, platform encoding: Cp1252 OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows" ... [DEBUG] Executing: cmd.exe /X /C "D:\jenkins\tools\maven221\bin\mvn.bat -B -X -D maven.repo.local=D:\Work\LocalRepository -P alwaysOn,codesign clean verify" [INFO] Error stacktraces are turned on. [INFO] Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01 0200) >>> [INFO] Java version: 1.6.0_30 >>> [INFO] Java home: C:\Program Files\Java\jdk1.6.0_30\jre (Invalid JDK, should be c:\java32) [INFO] Default locale: sv_SE, platform encoding: Cp1252

          James Nord added a comment -

          @Christer What version of the maven release plugin do you use?

          can you run a freestyle build on this node and output the result of "set" in a batch script?

          James Nord added a comment - @Christer What version of the maven release plugin do you use? can you run a freestyle build on this node and output the result of "set" in a batch script?

          James Nord added a comment -

          "but once I do a "Perform Maven Release" jenkins select the default 64 bits JDK instead of the configured 32 bits, which is configured in jenkins-slave.xml"

          So you have set JAVA_HOME in the slave environment config as well?

          James Nord added a comment - "but once I do a "Perform Maven Release" jenkins select the default 64 bits JDK instead of the configured 32 bits, which is configured in jenkins-slave.xml" So you have set JAVA_HOME in the slave environment config as well?

          James Nord added a comment -

          and one last thing - What type of slaves are you seeing this issue on?

          e.g.
          Dumb slave launched by jnlp
          or
          Jenkins managed DCOM.

          James Nord added a comment - and one last thing - What type of slaves are you seeing this issue on? e.g. Dumb slave launched by jnlp or Jenkins managed DCOM.

          James Nord added a comment -

          still can not reproduce in my environment and request for more info have not been responded to.

          James Nord added a comment - still can not reproduce in my environment and request for more info have not been responded to.

            Unassigned Unassigned
            pascalleclercq pascalleclercq
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: