Jenkins version: Jenkins ver. 2.107.2
How to configure the Jenkins project to use the custom JDK with Maven?
I have added JDK in the Global Tool Configuration and Maven with automatically install. I add two version of JDK.
Then I create a maven project by specifying one of the JDK and one of Maven. But I always get the error of mvn
cannot find the java
as JDKfollows:
/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/maven- 3.5.3/bin/mvn package
/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/maven-3.5.3/bin/mvn: exec: line 199:
/var/jenkins_home/tools/hudson.model.JDK/jdk8-172/bin/java: not found
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE
Then I try a lot of methods, only the system OpenJDK is work (chose JDK with System on the Jenkins project)
I also try
- config JAVA_HOME to the installed JDK
- config Tool Path
I also check the mvn and java in the Jenkins master(I use Docker to run the Jenkins), the JAVA_HOME is the OpenJDK and the mvn is not set.