last day (14 days later) » 

3:22 PM
0
Q: Unable to execute maven command on jenkins

RameshwarI have a jenkins job that checks out code from TFS and executes a test class using testng.xml I have Maven properly installed in my machine in C:\JenkinsDependencies\apache-maven It has mvn.bat file in its bin folder. But when I execute my job, it fails with the following error. Checking ...

 
ilj
do you have your JAVA_HOME and M2_HOME variables set for jenkins user?
 
On the slave machine where the code will be check out, I have set MAVEN_HOME AND JAVA_HOME set. What should M2_HOME point to?
 
ilj
M2_HOME=/path/to/maven-3.2.5, so that when it does PATH=PATH:M2_HOME/bin, your mvn.bat is there.
 
Should I append %M2_HOME%\bin in my PATH?
 
ilj
from your error message, it looks like Jenkins is able to find your maven. so just setting JAVA_HOME and adding it to PATH should be fine.
when you run it manually on the Jenkins server, do you use the same user?
 
3:22 PM
I always use the same user
setting JAVA_HOME and adding %JAVA_HOME%/bin to PATH did not work
hi
All these variables have to be set on the slave machine right?
I also set M2_HOME and added %M2_HOME%/bin to path. This did not do the trick
 
ilj
hi
so, you're saying it runs fine when you try it manually and fails when run by Jenkins?
 
yes
 
ilj
since i don't believe in magic :-) it must mean that something is different in the way your environment is set up when you run it manually and when Jenkins runs it.
try printing all environment variables from Jenkins build and from your session.
 
let me try that. and I'll let you know the result
should the environment variables be set on slave or master?
 
ilj
3:37 PM
they should be set on the machine where you're trying to run your tests.
 
you mean on the machine where the SCM checksout the source code?
 
ilj
i'm a little out of ideas. with Linux, i'd suggested running sh -x mvn.sh blah, but windows ..
 
ok. no problem. Thanks for your precious time :)
 
ilj
added this link as answer to your question.
 
4:16 PM
This is the output.
Does this make any sense for you. I could figure out just 80% of it.
C:\JenkinsRoot\workspace\TFS_LN_Mobile>REM ----------------------------------------------------------------------------

C:\JenkinsRoot\workspace\TFS_LN_Mobile>REM Licensed to the Apache Software Foundation (ASF) under one

C:\JenkinsRoot\workspace\TFS_LN_Mobile>REM or more contributor license agreements. See the NOTICE file

C:\JenkinsRoot\workspace\TFS_LN_Mobile>REM distributed with this work for additional information

C:\JenkinsRoot\workspace\TFS_LN_Mobile>REM regarding copyright ownership. The ASF licenses this file
 

last day (14 days later) »