There are various ways to do this, and I'm sure Jenkins has a way that is more robust, but, at a minimum, you can try to change the first sh-bang line to: #!/bin/bash -l Remove that explicit sourcing line from the job. We are assuming Java 1.7.0.60 as installed version for this tutorial. Step 2 - Set JAVA Environment. Set the JAVA_HOME environment variable to point to the base directory location where Java is installed on your machine. For example −.

Hudson uses the configured JDK for a maven build but does not set the JAVA_HOME property. So if you try to make a release the prepare is executed against the configured jdk but the perform is executed against the default JDK. We have a couple of builds which depends on the IBM JDK. We have configured whe jobs appropriately and it is working for snapshot builds. When running a release build the JDK tomcat is running on (Sun JDK) is used instead.

When we set the JAVA_HOME explicitely in the job it works. But this is a mess as we have to enter the full path to the jdk (and this is not the same on all slaves).

Hudson should set JAVA_HOME for the current build or - at least - provide a variable which holds the path to the configured JDK. Jesus vigo revisits how to create a usb installer for os x yosemite windows 10. This a blocking issue at our site! Thanks for the suggestion.

I saw this plugin on my research but found that it is not the best way as it does not export JAVA_HOME but something like SUN_1_6_HOME - so we need an additional config like exporting a parameter 'JAVA_HOME' with the value 'SUN_1_6_HOME'. I will check if it could be used as a workaround Indeed it is better as we do not need to know the full path (and only need to know the transformation algorithm from the JDKs name). For a long term solution the JAVA_HOME should be exported as it does not make any sense to NOT export it. Added a comment - 2010-06-15 02:31 Thanks for the suggestion. I saw this plugin on my research but found that it is not the best way as it does not export JAVA_HOME but something like SUN_1_6_HOME - so we need an additional config like exporting a parameter 'JAVA_HOME' with the value 'SUN_1_6_HOME'. I will check if it could be used as a workaround Indeed it is better as we do not need to know the full path (and only need to know the transformation algorithm from the JDKs name).

For a long term solution the JAVA_HOME should be exported as it does not make any sense to NOT export it. Added a comment - 2010-06-18 09:24 I found out a little more and it seems to be a little more complex than originally thought. Hudson DOES define the used JDK as JAVA_HOME. This is working when the build runs on the master. When running on a slave (we use the ssh-slaves-plugin) this Environment-setting is lost. On the slave-configuration-page we define an environment variable JAVA_HOME (needed so that hudson is able to start the slave as java is not on the path) and every build on the slaves uses this variable. On Jenkins 1.575, working against Windows Server 2012, setting the JDK in Jenkins provides the option to input the JAVA_HOME variable, and that worked around the issue for me.