Sunday, May 26, 2019

Cannot run program "mvn" (in directory : error=2, No such file or directory

Note : In below scenario jenkins was deployed in Linux container

Scenario:  Jenkins build failed with error.

java.io.IOException: error=2, No such file or directory
 at java.lang.UNIXProcess.forkAndExec(Native Method)
 at java.lang.UNIXProcess.(UNIXProcess.java:247)
 at java.lang.ProcessImpl.start(ProcessImpl.java:134)
 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
Caused: java.io.IOException: Cannot run program "mvn" (in directory "/var/jenkins_home/workspace/atmosphere"): error=2, No such file or directory



Fix:
The issue was due to absence of Maven files in container. To deploy Maven files , follow these steps:

  • Go to Global Tool Configuration (http://localhost:xxxx/configureTools/) or navigate Jenkins Home Page - > Manage Jenkins - > Global Tool Configuration
  • Scroll down and make the below configuration under Maven Section
  • Click Save
  • In Jenkins , go to teh Jenkins job and select configure
  • scroll down to BUILD Section and select MAVEN_HOME from dropdown
  • Rebuild Project



No comments:

Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.

Error when installing NPM  Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile. Fix: Run command and try a...