0

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

Gherbi Hicham
  • 2,416
  • 4
  • 26
  • 41
zs23000
  • 3
  • 2

1 Answers1

0

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

  • Thanks for your help, I think that it is not the same issue, mvn --version works fine for me and I can build my program out of jenkins builds. I will try to use maven plugin. Thank you again – zs23000 Aug 15 '17 at 08:44