14

This happens for both: maven projects, and freestyle projects, when maven target is envoked, it tries to execute mvn using absolute path.

[MY-Job] $ tools/Maven/Jenkins_Private_Maven/bin/mvn -f cc/pom.xml -Ddeploy_env=xxx.dev.prv   -Dbranch=dev -D-Dsmdist.target=/opt/builds -U clean test -DtestGroups=unit,delegate -Do verride:server=xxx.dev.prv
FATAL: command execution failed 
java.io.IOException: Cannot run program "tools/Maven/Jenkins_Private_Maven/bin/mvn" (in    directory "workspace/MY-Job"): java.io.IOException: error=2, No such file or directory

I can see that mvn is installed at user's home :

/home/jenkins/tools/Maven/Jenkins_Private_Maven/bin/mvn  

but it's trying to run it from the workspace:

/home/jenkins/workspace/MY-Job/tools/Maven/Jenkins_Private_Maven/bin/mvn
Mike
  • 1,176
  • 3
  • 14
  • 26

4 Answers4

24
  1. Add the default maven installation under (Jenkins -> configuration) Jenkins -> configuration -> Maven

  2. Goto the failing job and make sure you choose the default maven installation from dropdown Config in failing Job

  3. Run the job. Success!

Amit Sharma
  • 5,844
  • 5
  • 25
  • 34
  • In new Jenkins version 2.x it's under Global Tool Configuration under Manage Jenkins and 2nd step is not required. I'm not sure with newer version is it necessary at all ? – vikramvi Oct 07 '16 at 13:16
10

Are you sure you have set up Maven in Jenkins -> configuration like this

enter image description here

I have hunch you have a accidental **"."** current directory reference somewhere in your maven set up.

appbootup
  • 9,537
  • 3
  • 33
  • 65
1

This looks like an auto installed Maven by Jenkins. In which case the previous answers are not correct.

It would seem in this occasion that you have not specified a "remote fs root" for your slave in the salve setup - later versions of Jenkins flag not setting this up correctly as an error.

slave config screen

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
James Nord
  • 11
  • 1
0

in Jenkins 2.43:

Manage Jenkins -> Global Tool Configuration -> Maven

enter image description here

Nik Kashi
  • 4,447
  • 3
  • 40
  • 63
  • if maven have installed, then uncheck 'Install automatically' and specify maven name and path. Finally specify maven name in job config instead default – frank Mar 31 '18 at 02:16