Can Jenkins set JAVA_HOME?

2,865 views
Skip to first unread message

Asmann, Roland

unread,
Apr 7, 2011, 5:44:04 AM4/7/11
to jenkins...@googlegroups.com
Hi all,

I am running integration-tests on Jenkins and I am currently having
problems with the JAVA_HOME variable...

On the system, the JAVA_HOME is set to a SUN JDK 1.6. For my builds
(with Maven) and the tests (JBoss) I need an IBM JDK 1.6.
The builds work perfectly, but no matter what I try, I can't get the
JBoss to start with the IBM JDK!

The best solution of course would be to change the default JAVA_HOME,
but unfortunately I am not allowed to do this (I have no access to the
machine) nor do they want to change it -- probably because other builds
or programs will be influenced.

Is there a way to have Jenkins set the JAVA_HOME for the 'non-Maven'
part of the build? And probably the PATH variable is set too, so I will
need to override that as well.
Is this possible? And how?

Thanks.

--
Roland Asmann
Senior Software Engineer

adesso Austria GmbH
Floridotower 26. Stock T +43 1 2198790-27
Floridsdorfer Hauptstr. 1 F +43 1 2198790-927
A-1210 Wien M +43 664 88657566
E roland...@adesso.at
W www.adesso.at

-------------------------------------------------------------
>>> business. people. technology. <<<
-------------------------------------------------------------

Manuel Doninger

unread,
Apr 7, 2011, 5:58:39 AM4/7/11
to jenkins...@googlegroups.com
If you choose another JDK for that project (Project configuration ->
JDK, should be a drop down list, if you have configured all JDKs in
the global configuration), then Jenkins should automatically set
JAVA_HOME for that build to the right JDK (at least it works here).

Manuel

Manuel Doninger

unread,
Apr 7, 2011, 6:00:39 AM4/7/11
to jenkins...@googlegroups.com
Forgot one point: How do you call JBoss? If the build in Jenkins
starts JBoss (which i think it is), it should take the JAVA_HOME set
in Jenkins, and that should point to your IBM JDK. Or is it a separate
Job, triggered by the build job?

Manuel

Asmann, Roland

unread,
Apr 7, 2011, 6:04:31 AM4/7/11
to jenkins...@googlegroups.com
The job itself is built with the correct JDK, no problems there.

JBoss is started with the jboss-maven-plugin -- in other words: by Maven
itself. That is where the problems start.

Roland

Nord, James

unread,
Apr 7, 2011, 4:13:22 PM4/7/11
to jenkins...@googlegroups.com
Hi Roland,

There are other report of this (for instance the m2release plugin) but I've never been able to reproduce it.
https://issues.jenkins-ci.org/browse/JENKINS-7886

This is most likely the same underlying issue - but when I went through the code it does set JAVA_HOME.
https://github.com/jenkinsci/jenkins/blame/master/core/src/main/java/hudson/model/JDK.java

If you could provide details of your environment it may help to reproduce
(what slave mode do you use - if any - what environment does each slave have, OS, java version etc...)

Do you have only one global JDK configured in hudson - or many?

/James
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postm...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************

Asmann, Roland

unread,
Apr 7, 2011, 4:49:27 PM4/7/11
to jenkins...@googlegroups.com
Hi James,

I know about the issue with the release-plugin, that one can't be blamed
on Jenkins, because it sets the default JDK and not the configured one
-- at least in the last version I checked (I believe that was
0.7.0-SNAPSHOT back in december).

The only thing I see in that code is that a Map is filed with a key
'JAVA_HOME' and a value to a JDK. I don't see it being set in the
current session anywhere... But that might happen in another piece of code?

We currently use only one server for Jenkins. The company is just
starting CI so for now that is enough.

The server is running Linux, although I can't tell you which
distribution -- I don't have access to the machine itself and I can't
get into the Jenkins configuration.
Configured are 4 JDKs
- SUN JDK 1.5
- SUN JDK 1.6
- IBM JDK 1.5
- IBM JDK 1.6

The default JDK is the SUN JDK 1.6.

I've also tried to parameterize my build -- I read somewhere that this
works -- but this also doesn't do anything for me.

Thanks.

Roland
Reply all
Reply to author
Forward
0 new messages