Reputation: 9586
Configuring Jenkins (2.121.3) to use JDK 12 in the Global Tool Configuration->JDK installations... menu using "Download URL for binary archive" produces the following error when performing a build:
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE
How can I resolve this issue?
Upvotes: 2
Views: 5193
Reputation: 3747
As Robert Bain states, it is because there is a sub folder in the JDK archive.
Using more recent versions of Jenkins (2.375.1 in this instance), you can specify this sub folder in the Jenkins setup in the "Subdirectory of extracted archive" option. Eg:
Upvotes: 0
Reputation: 9586
The tar file has a directory called jdk-12 inside it, so when Jenkins extracts it, the named jdk folder is not the direct parent of the bin directory.
/var/jenkins_home/tools/hudson.model.JDK/Java12/jdk-12/bin
should be
/var/jenkins_home/tools/hudson.model.JDK/Java12/bin
To fix this, extract the tar file, go into the jdk-12 folder, tar czf openjdk-12_linux-x64_bin.tar.gz *
, upload it somewhere accessible to Jenkins and put the URL in the "Download URL for binary archive" field in the Global Tool Configuration->JDK installations... installer.
Upvotes: 0