1

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

  1. config JAVA_HOME to the installed JDK
  2. 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.

Xin Meng
  • 1,982
  • 3
  • 20
  • 32
  • is mvn -v showing correctly ?.. in MVN -V command JAVA_HOME is pointing the JRE folder like this :- C:\Program Files\Java\jdk1.8.0_45\jre – Pranavadurai May 01 '18 at 17:15
  • because I use the docker, so I run `mvn -v` in the bin/bash not work (exec -it xxx /bin/bash). – Xin Meng May 01 '18 at 17:29
  • /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/maven-3.3.9/bin/mvn -v Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11 -10T16:41:47+00:00) Maven home: /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/maven-3.3.9 Java version: 1.8.0_151, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-1.8-openjdk/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-693.21.1.el7.x86_64", arch: "amd64", family: "unix" – Xin Meng May 01 '18 at 17:30
  • if I run mvn with auto install path, the Java Home will display the system jre version – Xin Meng May 01 '18 at 17:32
  • Possible duplicate: https://stackoverflow.com/questions/49737624/jenkins-blue-ocean-maven-doesnt-see-java/ – Arigion Sep 02 '18 at 13:32

0 Answers0