Configuring JDK with Jenkins/Gradle

We’ve had a lot of trouble getting Jenkins to recognize the correct JVM when using the gradle plugin. What is the correct approach for getting it to always use the JDK 1.6?

The JDK drop down seems to have no effect (what populates the drop down anyway?). Setting JAVA_HOME on the box itself isn’t working.

thanks for any thoughts

You can configure the contents of the JDK dropdown by going to Manage Jenkins | Configure System | JDK. You should be able to setup a reference to your desired JDK here, and then go to the individual job configuration and select it. This works as expected for our Gradle builds.

with jenkins, you can add a pre-build ‘script shell’ action, do a "set JAVA_HOME=<path_to_your_jdk>

when execution your maven goals, this JAVA_HOME will be used :wink: