Maven not recognized in jenkins

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

After googling, I changed MAVEN_HOME as **%M2_HOME%\bin** in the Jenkin-Maven configuration. However, this 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, operating program or batch file

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

  • Finished: FAILURE

Edited: analysis added

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

Edited: tied to configuration Maven-JDK-Git Configuration in Jenkins

Maven is available in the PATH variables

+6
source share
2 answers

Suppose your Tomcat server is running as a Windows service.

Have you created 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% 
+4
source

I'm sure you installed Maven 3.3, which renamed mvn.bat to mvn.cmd

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

+5
source

Source: https://habr.com/ru/post/987632/


All Articles