arielma
arielma

Reputation: 1398

JAVA_HOME gives me wrong value on node

I have Jenkins node with the below configuration for JavaPath:

/usr/java/jdk1.8.0_131/bin/java

I wrote a simple Jenkins job which prints JAVA_HOME:

#!/bin/ksh echo "JAVA_HOME=${JAVA_HOME}" echo $PATH for some reason, the output I'm getting is:

JAVA_HOME=/usr/java/jdk1.8.0_31 why it doesn't use the value which used to load the node? I don't have such Java reference on the node. BTW, it's Jenkins container, not VM

Upvotes: 1

Views: 165

Answers (1)

Unforgettable631
Unforgettable631

Reputation: 1020

There can be a JAVA_HOME configured under Manage Jenkins -> Global Tool Configuration -> JDK. If you provide multiple, you need to specify the Java version that will be used by the build execution.

You can also use existing Java available on the system as well.

For example we have this in pipeline script to identify & print defined tools. tool name is the Name of the JDK defined in Global Tool Configuration:

def jdktool = tool name: 'JDK-1.8.0', type: 'hudson.model.JDK'
env.JAVA_HOME = "${jdktool}"

Upvotes: 1

Related Questions