Alternate JDK on slave box

21 views
Skip to first unread message

Gilles Devaux

unread,
Jan 27, 2015, 3:57:44 PM1/27/15
to jenkins...@googlegroups.com
Hi,

I have installed two JDKs on a slave box, JDK7 (default) and JDK8 (without update-alternatives). I'm trying to build something with the JDK8 but no luck.

I'm setting "JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-x64/" in several places, String build parameter, inject environment, something like this in the DSL:

```
wrappers {
                environmentVariables {
                    env('JAVA_HOME', '/usr/lib/jvm/jdk-8-oracle-x64/')
                }
            }
parameters {
                stringParam('JAVA_HOME','/usr/lib/jvm/jdk-8-oracle-x64/')
            }
environmentVariables(
                    JAVA_HOME: '/usr/lib/jvm/jdk-8-oracle-x64/'
            )
```

But maven is still started with the system JDK:

Relevant logs:

```
00:00:00.001 [EnvInject] - Loading node environment variables.
00:00:00.420 [EnvInject] - Preparing an environment for the build.
00:00:00.420 [EnvInject] - Keeping Jenkins system variables.
00:00:00.629 [EnvInject] - Keeping Jenkins build variables.
00:00:01.255 [EnvInject] - Injecting as environment variables the properties content 
00:00:01.255 JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-x64/
00:00:01.256 
00:00:01.256 [EnvInject] - Variables injected successfully.
00:00:01.257 [EnvInject] - Injecting contributions.
00:00:01.258 Building remotely on linux-ba-awsuse1-jenkinsslave-a1 in workspace ...
00:00:03.357 Creating version: 0.8.0-111-24-2015-01-27-825bee6
00:00:03.361 [EnvInject] - Executing scripts and injecting environment variables after the SCM step.
00:00:03.570 [EnvInject] - Injecting as environment variables the properties content 
00:00:03.570 JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-x64/
00:00:03.673 
00:00:03.674 [EnvInject] - Variables injected successfully.
00:00:05.865 Copied 1 artifact from " [8mha:AAAAoR+LCAAAAAAAAP9b85aBtbiIQSajNKU4P08vOT+vOD8nVc+jsiC1KCczL9svvyTVzHb1RttJBUeZGJg8GdhyUvPSSzJ8GJhLi3JKGIR8shLLEvVzEvPS9YNLijLz0q0rihik0IxzhtAgwxgggJGJgaGiAMjQLWFQ0c/KT9JPy8/JyS/XLS5NT08tLskE6tAty0wtjy9KBVH6AD2dlyipAAAA [0mfollow-suggestions-view_review (SCM Checkout)" build number [8mha:AAAApB+LCAAAAAAAAP9b85aBtbiIQSajNKU4P08vOT+vOD8nVc+jsiC1KCczL9svvyTVzHb1RttJBUeZGJg8GdhyUvPSSzJ8GJhLi3JKGIR8shLLEvVzEvPS9YNLijLz0q0rihik0IxzhtAgwxgggJGJgaGiAMhgKmFQ18/KT9JPy8/JyS/XLS5NT08tLskE6tAty0wtjy9KBVH6Rib6AAebm7CsAAAA [0m24
00:00:07.081 [workspace-24_2015-01-27_20-45-28] $ /bin/sh -xe /tmp/hudson6869963651105314926.sh
00:00:07.094 + [ -f workspace.tgz ]
00:00:07.094 + tar xzf workspace.tgz
00:00:07.125 + rm workspace.tgz
00:00:07.797 Parsing POMs
00:00:10.818 maven3-agent.jar already up to date
00:00:11.351 maven3-interceptor.jar already up to date
00:00:11.665 maven3-interceptor-commons.jar already up to date
00:00:11.869 [workspace-24_2015-01-27_20-45-28] $ java -cp /spotify/jenkins-agent/maven3-agent.jar:/spotify/jenkins-agent/tools/hudson.tasks.Maven_MavenInstallation/_usr_bin_mvn/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /spotify/jenkins-agent/tools/hudson.tasks.Maven_MavenInstallation/_usr_bin_mvn /spotify/jenkins-agent/slave.jar /spotify/jenkins-agent/maven3-interceptor.jar /spotify/jenkins-agent/maven3-interceptor-commons.jar 44050
00:00:12.750 <===[JENKINS REMOTING CAPACITY]===>channel started
00:00:24.609 log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
00:00:24.610 log4j:WARN Please initialize the log4j system properly.
00:00:30.355 Executing Maven:  -B -f ... -X compile
00:00:33.063 Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 13:51:28+0000)
00:00:33.064 Maven home: /spotify/jenkins-agent/tools/hudson.tasks.Maven_MavenInstallation/_usr_bin_mvn
00:00:34.009 Java version: 1.7.0_60, vendor: Oracle Corporation
00:00:34.013 Java home: /usr/lib/jvm/jdk-7-oracle-x64/jre
00:00:34.014 Default locale: en_US, platform encoding: UTF-8
00:00:34.024 OS name: "linux", version: "3.13.0-24-generic", arch: "amd64", family: "unix"
```

The parameters and injectedEnvVars panels in the build show the JAVA_HOME

Any idea?

Thanks

--Gilles

Les Mikesell

unread,
Jan 27, 2015, 4:11:44 PM1/27/15
to jenkinsci-users
On Tue, Jan 27, 2015 at 2:57 PM, Gilles Devaux <gilles...@gmail.com> wrote:
> Hi,
>
> I have installed two JDKs on a slave box, JDK7 (default) and JDK8 (without
> update-alternatives). I'm trying to build something with the JDK8 but no
> luck.
>
> I'm setting "JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-x64/" in several places,
> String build parameter, inject environment, something like this in the DSL:
>
> ```
> wrappers {
> environmentVariables {
> env('JAVA_HOME', '/usr/lib/jvm/jdk-8-oracle-x64/')
> }
> }
> parameters {
> stringParam('JAVA_HOME','/usr/lib/jvm/jdk-8-oracle-x64/')
> }
> environmentVariables(
> JAVA_HOME: '/usr/lib/jvm/jdk-8-oracle-x64/'
> )
> ```

I'm not using maven, but doesn't this work like the other JVM
settings? That is, give the JVMs names in the global configuration,
then set/override the location in the node config tools section, and
then pick the JDK name in the job config. The location should get
exported as JAVA_HOME.

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

John Mellor

unread,
Jan 27, 2015, 4:22:41 PM1/27/15
to jenkins...@googlegroups.com
Its been a while since I did a maven build under Jenkins or Hudson, but somewhere it notes that the system jdk is used to fire up Java-based build steps. There should be a checkbox somewhere in the config to start a separate Java instance and NOT use the default system jdk. Of course, that will require forking and starting up the different jdk, so it will slow your build down slightly...
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAOAgVpzZup6cZ_ECmWV9hsORWx916Obp%3DJVbw-a%2BKmFjoAjoGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages