1
votes

I am trying to setup jenkins on docker in my windows machine. Everything was going smooth until I configured the maven goal in Jenkins. It looks like maven is overlooking the Jenkins_home path configured while starting the docker. I used the following command during startup

docker run -p 8080:8080 -p 50000:50000 -v //D/jenkins:/var/jenkins_home Jenkins

I also tried the following

docker run -p 8080:8080 -p 50000:50000 -v jenkins_home://D/jenkins_workspace jenkins

but I keep getting the error

[crazywebapp_dev] $ mvn clean install

FATAL: command execution failed 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/crazywebapp_dev"): error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at hudson.Proc$LocalProc.(Proc.java:249)

I believe it has got to do something with maven because the Jenkins workspace is getting created in my D: drive and the code is checked out successfully from bit bucket and the workspace contents shows up in Jenkins. I have also noticed that even though the workspace is created in my D: drive, Jenkins_home still shows up as /var/Jenkins_home in the Jenkins config page. Please help me figure this out.

1
The issue is located here: ` Cannot run program "mvn" (in directory "/var/jenkins_home/workspace/crazywebapp_dev"): error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at .. That means your jenkins can't find the mvn` program. This means Maven is not correctly configured in your jenkins tools configuration..khmarbaise
@khmarbaise . Thank you. That is exactly what it was . I was expecting an error more in term of "This command does not exist" and misunderstood the whole thing.Aravind A

1 Answers

2
votes

I have also noticed that even though the workspace is created in my D: drive, Jenkins_home still shows up as /var/Jenkins_home in the Jenkins config page. Please help me figure this out.

From the containers perspective, there is no D: drive, the jenkins_home will always be /var/jenkins_home inside the container.

The syntax -v //D/jenkins:/var/jenkins_home means mount D:\jenkins onto /var/jenkins_home inside the container. This will effectively just replace or backup the containers jenkins home in the jenkins folder.

The syntax -v jenkins_home://D/jenkins_workspace is not useful. It means "create" a /D/jenkins_workspace directory inside the container and use a named volume called jenkins_home to backup this folder. This is not useful.

The main problem that you have, is that maven is not installed inside the jenkins container. Thus jenkins clearly can't find it. You need to configure maven to be installed. You can do that in jenkins, by going to:

Manage Jenkins > Configure System > Maven section and then configure it to install maven automatically.