问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/55540287/jenkins-failure-java-12-openjdk-the-java-home-environment-variable-is-not-defi