Jenkins
Installed from docker image jenkinsci/docker - README.me
Plugins
configureTools
Jenkinsfile
pipeline {
agent any
stages {
stage('Clean') {
steps {
withMaven(maven: 'Default',jdk: 'Java 10') {
sh "echo JAVA_HOME=$JAVA_HOME"
sh "mvn clean"
}
}
}
}
}
Error
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Clean)
[Pipeline] withMaven
[withMaven] Options: []
[withMaven] Available options:
[withMaven] using JDK installation Java 10
[withMaven] using Maven installation 'Default' [Pipeline] {
[Pipeline] sh
+ echo 'JAVA_HOME=/var/jenkins_home/tools/hudson.model.JDK/Java_10'
JAVA_HOME=/var/jenkins_home/tools/hudson.model.JDK/Java_10
[Pipeline] sh
+ mvn clean -B -V
----- withMaven Wrapper script -----
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
[Pipeline] }
Question
What I don't understand is why the $JAVA_HOME
is incorrect ? (should be /var/jenkins_home/tools/hudson.model.JDK/Java_10/jdk-10.0.2, no ?)
I've try to set it on the global properties of the jenkins system configuration, but I've get the same output/error (and don't want to set it here as there can be other java_home for other java installation)
What am I missing ?
EDIT Opened an issue to Jenkins (Jira - JENKINS-54959)
EDIT 2
After some discussion with the Jenkins crews, we finally found the missing option.
As the archive contains a subdirectory (here jdk-10.0.2), we need to inform the de-zipper with the subdir field
Optional subdirectory of the downloaded and unpacked archive to use as the tool's home directory
so now, I got the error
[Pipeline] withMaven
[withMaven] Options: []
[withMaven] Available options: [withMaven] using JDK installation Java 10
[withMaven] using Maven installation 'Default'
[Pipeline] {
[Pipeline] sh
+ echo 'JAVA_HOME=/var/jenkins_home/tools/hudson.model.JDK/Java_10/jdk-10.0.2'
JAVA_HOME=/var/jenkins_home/tools/hudson.model.JDK/Java_10/jdk-10.0.2
[Pipeline] sh
+ mvn clean -B -V
----- withMaven Wrapper script -----
/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Default/bin/mvn: exec: line 199: /var/jenkins_home/tools/hudson.model.JDK/Java_10/jdk-10.0.2/bin/java: not found
[Pipeline] }
OK,
by installing the Java 11 Support Preview is available in Jenkins 2.155+ I'm not anymore having the java error \o/
I'm closing this problem :)