0
votes

When jenkins tries to build my program, the jenkins build fails with the error mvn is not recognized as internal or external command. Here is what jenkins runs :

cmd.exe /C "mvn -f spring-boot-samples\spring-boot-sample-atmosphere\pom.xml compile && exit %%ERRORLEVEL%%"

Maven is correctly set in my computer, when I execute the previous command manually from the jenkins workspace, the build works perfectly and the jar file is generated

Seems that jenkins needs his one environment variable ?

Thank you, regards

1

1 Answers

0
votes

Duplicate. See 'mvn' is not recognized as an internal or external command, or Apache Maven install "'mvn' not recognized as an internal or external command" after setting OS environmental variables? or Maven not recognized in Jenkins

I recommend not relying on the jenkins' host configuration. Jenkins is good at sandboxing its jobs and outsourcing the execution to agents, which might not have all tools installed on the host directly. Instead use jenkins' provisioning mechanism and plugins if possible. For instance the maven project plugin: https://wiki.jenkins.io/display/JENKINS/Maven+Project+Plugin