Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins executing maven from incorrect path

Tags:

maven

jenkins

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
like image 531
Mike Avatar asked Dec 11 '12 15:12

Mike


1 Answers

  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!

like image 183
Amit Sharma Avatar answered Sep 21 '22 00:09

Amit Sharma