Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven not recognized in Jenkins

Tags:

maven

jenkins

I have installed Tomcat 7 on Windows 8, on which Jenkins is deployed. I configured the JDK, Ant and Maven in the Jenkin settings. In the Maven section, I gave a name as LocalMaven and the MAVEN_HOME as C:\Techie\apache-maven. When I did a test build, it gave me the following error that the mvn.bat is not recognized. Then I checked by entering mvn command in CMD. It gave some maven statements, which means maven is available in the PATH variables.

After googling, I changed the MAVEN_HOME as **%M2_HOME%\bin** in Jenkin-Maven configuration. Still it did not work.

LOG:

  • [workspace] $ cmd.exe /C '"mvn.bat -f HighScoresServiceClient compile && exit %%ERRORLEVEL%%"'

  • 'mvn.bat' is not recognized as an internal or external command, operable program or batch file

  • Build step 'Invoke top-level Maven targets' marked build as failure

  • Finished: FAILURE

Edited: Added the analysis

The command executed by Jenkins is [workspace] $ cmd.exe /C '"mvn.bat -f String-replacer compile && exit %%ERRORLEVEL%%"' where mvn.bat is not a valid command and so Jenkins errors out as follows that 'mvn.bat' is not recognized as an internal or external command, I think Jenkins should call the command as mvn and not mvn.bat. Can some experts correct me if I am wrong? Please let me know how to change this behaviour if I am right.

Edited: Attached the Configuration Maven-JDK-Git Configuration in Jenkins

Maven is available in the PATH variables

like image 903
Anand Avatar asked May 21 '15 05:05

Anand


2 Answers

I suppose your Tomcat server is running as a Windows service.

Did you create your MAVEN_HOME and M2_HOME as system environment variables? (idem for your PATH)

Another solution is to configure your variables in the apache-tomcat/bin/setenv.bat file:

set MAVEN_HOME=C:\Techie\apache-maven
set PATH=%MAVEN_HOME%\bin;%PATH%
like image 140
Bruno Lavit Avatar answered Oct 07 '22 02:10

Bruno Lavit


I bet you've installed Maven 3.3 that has mvn.bat renamed to mvn.cmd

There is a report on this issue in Jenkins JIRA: https://issues.jenkins-ci.org/browse/JENKINS-27525

like image 27
Alexei Barantsev Avatar answered Oct 07 '22 02:10

Alexei Barantsev