Jenkins using wrong JDK

9,287 views
Skip to first unread message

Farrukh Najmi

unread,
Sep 20, 2013, 9:39:53 AM9/20/13
to jenkins...@googlegroups.com
Hi Guys,

Initially all was well and my Jenkins config.xml was configured for just JDK7.
I then added a JDK6 installation to Jenkins config and did a new build manually.
The build failed and on examination I realized my project requires JDK7 to build.
So I edited my Jenkins config to delete the JDK6 installation I had added prior to previous build that had failed.
Now only the JDK7 installation was left in Jenkins config.

I did another build but now I see that it is still trying to build with JDK6 only instead of the JDK6 installation I had added from Oracle it is now using the JDK 6 that is part of my Ubuntu setup.

What am I doing wrong and how can I make Jenkins only use the JDK7 that I have configured?

--
Regards,
Farrukh Najmi

Ulli Hafner

unread,
Sep 20, 2013, 9:43:52 AM9/20/13
to jenkins...@googlegroups.com
What values are in your Java Version list box in you job configuration? Which Java Versions are visible in Jenkins global configuration? Please use the UI only...

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

signature.asc

Farrukh Najmi

unread,
Sep 20, 2013, 10:01:42 AM9/20/13
to jenkins...@googlegroups.com
I do not see a Java Version list box in my job config page in UI. I have expanded varios Advanced section in the page but still do not see Java Version list. I am using Jenkins version 1.531.

The only Java Version available in Jenkins global config is JDK 7.

One odd difference I notice in the logs for a successful build vs. failed build is that the failed build uses java command without fully qualified path while successful build uses fully qualified path to corect jdk.

#From bad build piucking up JDK 6
java -Djava.io.tmpdir=/var/lib/jenkins/tmp -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.4.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/boot/plexus-classworlds-2.4.2.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/conf/logging jenkins.maven3.agent.Maven31Main /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven /var/cache/jenkins/war/WEB-INF/lib/remoting-2.32.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.4.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.4.jar 46644

#From good build using JDK7
/var/lib/jenkins/tools/hudson.model.JDK/JDK_7/bin/java -Djava.io.tmpdir=/var/lib/jenkins/tmp -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.4.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/boot/plexus-classworlds-2.4.2.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/conf/logging jenkins.maven3.agent.Maven31Main /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven /var/cache/jenkins/war/WEB-INF/lib/remoting-2.32.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.4.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.4.jar 52130

This seems significant.

Many thanks for your help Ullrich!

Eric Pyle

unread,
Sep 20, 2013, 10:03:52 AM9/20/13
to jenkins...@googlegroups.com
I think you have picked up on the solution there. Either always use the full path to the desired Java installation, or alter your path so that 'which java' returns the correct path.

Eric

Farrukh Najmi

unread,
Sep 20, 2013, 10:11:35 AM9/20/13
to jenkins...@googlegroups.com

But I used the GUI option for Jenkins to install JDK from java.sun.com and never specified a fullpath location for JDK in the first place when I added a JDK7 installation.

Later I added and removed a JDK 6 installation. All was done via GUI.

So I am at a loss as to what went wrong and how I can recover from it. Thanks Eric for your help.

Eric Pyle

unread,
Sep 20, 2013, 10:15:14 AM9/20/13
to jenkins...@googlegroups.com
When you added the JDK 6 installation, most likely the installer altered your system path to place that installation first on the path. Try creating a new Jenkins job containing a shell script job step with the command "which java". That will tell you where the OS is looking when you call java without giving a full path.

Eric

Ulli Hafner

unread,
Sep 20, 2013, 10:22:28 AM9/20/13
to jenkins...@googlegroups.com
What job type are you using? I have a JDK Listbox right above the advanced project options section…
signature.asc

Farrukh Najmi

unread,
Sep 20, 2013, 10:32:38 AM9/20/13
to jenkins...@googlegroups.com
I am using job type of a maven multi-module project. There is no such JDK List Box that I see. Here is a screenshot of my project config:

http://wellfleetsoftware.com/files/tmp/screenshot.png

BTW, what determines whether the java command during build uses fully qualified path or not?

Thanks very much for your help Ulli!

On 09/20/2013 10:22 AM, Ulli Hafner wrote:
What job type are you using? I have a JDK Listbox right above the advanced project options section�

Am 20.09.2013 um 16:01 schrieb Farrukh Najmi <farruk...@gmail.com>:

I do not see a Java Version list box in my job config page in UI. I have expanded varios Advanced section in the page but still do not see Java Version list. I am using Jenkins version 1.531.

The only Java Version available in Jenkins global config is JDK 7.

One odd difference I notice in the logs for a successful build vs. failed build is that the failed build uses java command without fully qualified path while successful build uses fully qualified path to corect jdk.

#From bad build piucking up JDK 6
java -Djava.io.tmpdir=/var/lib/jenkins/tmp -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.4.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/boot/plexus-classworlds-2.4.2.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/conf/logging jenkins.maven3.agent.Maven31Main /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven /var/cache/jenkins/war/WEB-INF/lib/remoting-2.32.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.4.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.4.jar 46644

#From good build using JDK7
/var/lib/jenkins/tools/hudson.model.JDK/JDK_7/bin/java -Djava.io.tmpdir=/var/lib/jenkins/tmp -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.4.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/boot/plexus-classworlds-2.4.2.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/conf/logging jenkins.maven3.agent.Maven31Main /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven /var/cache/jenkins/war/WEB-INF/lib/remoting-2.32.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.4.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.4.jar 52130

This seems significant.

Many thanks for your help Ullrich!


On Friday, September 20, 2013 9:43:52 AM UTC-4, Ullrich Hafner wrote:
What values are in your Java Version list box in you job configuration? Which Java Versions are visible in Jenkins global configuration? Please use the UI only...

Am 20.09.2013 um 15:39 schrieb Farrukh Najmi <farruk...@gmail.com>:

Hi Guys,

Initially all was well and my Jenkins config.xml was configured for just JDK7.
I then added a JDK6 installation to Jenkins config and did a new build manually.
The build failed and on examination I realized my project requires JDK7 to build.
So I edited my Jenkins config to delete the JDK6 installation I had added prior to previous build that had failed.
Now only the JDK7 installation was left in Jenkins config.

I did another build but now I see that it is still trying to build with JDK6 only instead of the JDK6 installation I had added from Oracle it is now using the JDK 6 that is part of my Ubuntu setup.

What am I doing wrong and how can I make Jenkins only use the JDK7 that I have configured?


-- 
Regards,
Farrukh Najmi

Web: http://www.wellfleetsoftware.com

Farrukh Najmi

unread,
Sep 20, 2013, 11:17:39 AM9/20/13
to jenkins...@googlegroups.com
I am coming to the conclusion that something is not working misunderstood by me (or not working correctly) as to how Jenkins sets up its environment variables and specially the PATH and JAVA_HOME env vars.

I tried setting key env vars in global config.

Here is what it looks like in ~jenkins/config.xml:

  <globalNodeProperties>
    <hudson.slaves.EnvironmentVariablesNodeProperty>
      <envVars serialization="custom">
        <unserializable-parents/>
        <tree-map>
          <default>
            <comparator class="hudson.util.CaseInsensitiveComparator"/>
          </default>
          <int>3</int>
          <string>JAVA_HOME</string>
          <string>/var/lib/jenkins/tools/hudson.model.JDK/JDK_7</string>
          <string>MAVEN_HOME</string>
          <string>/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven</string>
          <string>PATH</string>
          <string>$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH</string>
        </tree-map>
      </envVars>
    </hudson.slaves.EnvironmentVariablesNodeProperty>
  </globalNodeProperties>

Still, Jenkins insists on running the unqualified java command which seems to be stuck on. All I did was add and remove a JDK 6 installation and I cannot seem to figure out a way out of this issue :-(

Ulli Hafner

unread,
Sep 20, 2013, 11:30:51 AM9/20/13
to jenkins...@googlegroups.com
Hmm, I have such a list box, for maven and freestyle builds.


Am 20.09.2013 um 16:32 schrieb Farrukh Najmi <farruk...@gmail.com>:

I am using job type of a maven multi-module project. There is no such JDK List Box that I see. Here is a screenshot of my project config:

http://wellfleetsoftware.com/files/tmp/screenshot.png

BTW, what determines whether the java command during build uses fully qualified path or not?

Thanks very much for your help Ulli!

On 09/20/2013 10:22 AM, Ulli Hafner wrote:
What job type are you using? I have a JDK Listbox right above the advanced project options section…
signature.asc

Farrukh Najmi

unread,
Sep 20, 2013, 12:00:08 PM9/20/13
to jenkins...@googlegroups.com
What version of jenkins are you running? I am running Jenkins 1.531.


On 09/20/2013 11:30 AM, Ulli Hafner wrote:
Hmm, I have such a list box, for maven and freestyle builds.

Am 20.09.2013 um 16:32 schrieb Farrukh Najmi <farruk...@gmail.com>:

I am using job type of a maven multi-module project. There is no such JDK List Box that I see. Here is a screenshot of my project config:

http://wellfleetsoftware.com/files/tmp/screenshot.png

BTW, what determines whether the java command during build uses fully qualified path or not?

Thanks very much for your help Ulli!

On 09/20/2013 10:22 AM, Ulli Hafner wrote:
What job type are you using? I have a JDK Listbox right above the advanced project options section�

Ulli Hafner

unread,
Sep 20, 2013, 12:15:14 PM9/20/13
to jenkins...@googlegroups.com
I'm on 1.531 too. I have no environment variables set, just 3 JDK configurations in Jenkins. Maybe that is different…

Are you running the build on a slave?

Ulli

Am 20.09.2013 um 18:00 schrieb Farrukh Najmi <farruk...@gmail.com>:

What version of jenkins are you running? I am running Jenkins 1.531.

On 09/20/2013 11:30 AM, Ulli Hafner wrote:
Hmm, I have such a list box, for maven and freestyle builds.

Am 20.09.2013 um 16:32 schrieb Farrukh Najmi <farruk...@gmail.com>:

I am using job type of a maven multi-module project. There is no such JDK List Box that I see. Here is a screenshot of my project config:

http://wellfleetsoftware.com/files/tmp/screenshot.png

BTW, what determines whether the java command during build uses fully qualified path or not?

Thanks very much for your help Ulli!

On 09/20/2013 10:22 AM, Ulli Hafner wrote:
What job type are you using? I have a JDK Listbox right above the advanced project options section…
signature.asc

Les Mikesell

unread,
Sep 20, 2013, 12:16:04 PM9/20/13
to jenkinsci-users
You should be able to use multiple JDK versions and select them by
job. In the global jenkins configuration under JDK installations,
give each JDK a name, then in the node configurations under tool
locations, add the appropriate path to each named JDK installation.
And in the job, pick the JDK version by name.

--
Les Mikesell
lesmi...@gmail.com

Farrukh Najmi

unread,
Sep 20, 2013, 12:30:01 PM9/20/13
to jenkins...@googlegroups.com
The fix was to make sure I had multiple JDKs configured in global
config. This enabled the JDK selection pulldown to be visible above
"Advanced Project Options" section. There I select a specific JDK (JDK 7
in my case) and all is well.

Note that I do not recall ever setting a JDK for my job explicitly.

It seems that Jenkins had originally correctly chosen on its own my only
configured JDK (instead of Default JDK).
When I added and deleted a second JDK then Jenkins on its own switched
to Default JDK (instead of the only configured JDK).

This seems to be unexpected behavior.

Geoff Cummings

unread,
Sep 20, 2013, 12:31:08 PM9/20/13
to jenkins...@googlegroups.com
You will only see the JDK list box in the job config if you have more
than one JDK installation configured in your main jenkins config page

Daniel Beck

unread,
Sep 20, 2013, 12:48:18 PM9/20/13
to jenkins...@googlegroups.com

Farrukh Najmi

unread,
Sep 20, 2013, 12:52:59 PM9/20/13
to jenkins...@googlegroups.com, m...@beckweb.net

I think the following issue is closer to this thread:

https://issues.jenkins-ci.org/browse/JENKINS-755

Thanks for the terrific help! Jenkins community rocks!

Diego Ballve

unread,
Oct 18, 2013, 9:34:57 AM10/18/13
to jenkins...@googlegroups.com
Hi Farrukh!

Thanks for sharing. Kinda silly I have to install 2 JDKs to be able to use one of them, but it resolved the problem.

br, Diego

Alexei Novikov

unread,
Mar 3, 2014, 1:05:48 PM3/3/14
to jenkins...@googlegroups.com
Your info is very helpful, thank you! You saved my day.

Les Mikesell

unread,
Mar 3, 2014, 1:45:52 PM3/3/14
to jenkinsci-users
I don't think you'd actually have to install the other JDK - just
configure jenkins with paths like you did...

But, if everything you are doing will work with a single JDK version,
consider yourself lucky.

--
Les Mikesell
lesmi...@gmail.com
Reply all
Reply to author
Forward
0 new messages