I run Jenkins 2.0 beta binary under Windows 10.
I declared a Maven installation "M3" under Global Tool Configuration.
I created the pipeline job with the following script:
node { git url: 'https://github.com/jglick/simple-maven-project-with-tests.git' def mvnHome = tool 'M3' bat "${mvnHome}\\bin\\mvn -B verify" }
I get the following error when installing Maven:
Started by user Administrateur [Pipeline] Allocate node : Start Running on master in C:\Program Files (x86)\Jenkins\workspace\myPipeline [Pipeline] node { [Pipeline] git Cloning the remote Git repository remote: Counting objects Receiving objects Resolving deltas Updating references Checking out Revision 7dac409d4bd2fec35a4ccde0cb424042cba671df (refs/remotes/origin/master) First time build. Skipping changelog. [Pipeline] tool Unpacking http://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip to C:\Program Files (x86)\Jenkins\tools\hudson.tasks.Maven_MavenInstallation\M3 on Jenkins [Pipeline] bat [myPipeline] Running batch script C:\Program Files (x86)\Jenkins\workspace\myPipeline>"C:\Program Files (x86)\Jenkins\tools\hudson.tasks.Maven_MavenInstallation\M3"\bin\mvn -B verify Error: JAVA_HOME not found in your environment. Please set the JAVA_HOME variable in your environment to match the location of your Java installation. [Pipeline] } //node [Pipeline] Allocate node : End [Pipeline] End of Pipeline ERROR: script returned exit code 1 Finished: FAILURE
Workaround: I have to declare explicitely JAVA_HOME environment variable in Manage Jenkins -> Configure System -> Global properties section. I set it to "C:\Program Files\Java\jdk1.8.0_77"
After that the build works correctly
Clearly I think on Global Tool Configuration, a Maven installation should be bind to a JDK installation to avoid such issue. Concretely in Maven widget a combobox should be present to select a JDK installation already configured above.
- is related to
-
JENKINS-28718 withTool
- Open