40

I'm doing a build on my Ubuntu 14.04 LTS but I'm getting the following:

Started by user anonymous
Building in workspace /var/lib/jenkins/workspace/videovixx
 > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > /usr/bin/git config remote.origin.url https://bitbucket.org/mdennis10/videovixx.git #     timeout=10
Fetching upstream changes from https://bitbucket.org/mdennis10/videovixx.git
 > /usr/bin/git --version # timeout=10
using .gitcredentials to set credentials
 > /usr/bin/git config --local credential.helper store --    file=/tmp/git6236060328558794078.credentials # timeout=10
 > /usr/bin/git fetch --tags --progress https://bitbucket.org/mdennis10/videovixx.git   +refs/heads/*:refs/remotes/origin/*
 > /usr/bin/git config --local --remove-section credential # timeout=10
 > /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > /usr/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision f5c53e95d33c1e15abd7519346c18ec6bc0c81d7      (refs/remotes/origin/master)
 > /usr/bin/git config core.sparsecheckout # timeout=10
 > /usr/bin/git checkout -f f5c53e95d33c1e15abd7519346c18ec6bc0c81d7
 > /usr/bin/git rev-list f5c53e95d33c1e15abd7519346c18ec6bc0c81d7 # timeout=10
[videovixx] $ mvn install package
FATAL: command execution failed
java.io.IOException: Cannot run program "mvn" (in directory    "/var/lib/jenkins/workspace/videovixx"): error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
    at hudson.Proc$LocalProc.<init>(Proc.java:244)
    at hudson.Proc$LocalProc.<init>(Proc.java:216)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:802)
    at hudson.Launcher$ProcStarter.start(Launcher.java:380)
    at hudson.Launcher$ProcStarter.join(Launcher.java:387)
    at hudson.tasks.Maven.perform(Maven.java:328)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
    at hudson.model.Build$BuildExecution.build(Build.java:199)
    at hudson.model.Build$BuildExecution.doRun(Build.java:160)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:533)
    at hudson.model.Run.execute(Run.java:1745)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:89)
    at hudson.model.Executor.run(Executor.java:240)
Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:186)
    at java.lang.ProcessImpl.start(ProcessImpl.java:130)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
    ... 15 more
Build step 'Invoke top-level Maven targets' marked build as failure
Archiving artifacts
Recording test results
Finished: FAILURE

I'm assuming that this caused by some linux security feature that stops the /var/lib/jenkins/workspace/videovixx from being created without the correct permissions which I might not have. Is this the problem and how do I solve it?

JavierSA
  • 783
  • 1
  • 10
  • 25
Mario Dennis
  • 2,986
  • 13
  • 35
  • 50
  • have you checked if Maven is installed for the current os user used by jenkins and that is on the path? seems maven is not available. – NeoP5 Nov 13 '14 at 10:49
  • What's also possible: _"/var/lib/jenkins/workspace/videovixx"): error=2, No such file or directory_ – Doe Johnson Nov 13 '14 at 13:26

8 Answers8

63

There are multiple things here.

You either didn't select Maven version in Job configuration. Or you didn't configure Jenkins to install a Maven version. Or you expected to use locally installed Maven on the Slave, but it's not configured for jenkins user.

Since I don't know what you've configured (or didn't configure) and what you expected to use, I can't answer directly, but I can explain how it works.

If you want to use locally installed Maven on master/slave

  • You must have Maven locally installed
  • You must be able to launch it with jenkins user
    1. Execute sudo jenkins, and then execute mvn on your Slave to verify that jenkins user can run mvn
    2. If that fails, you need to properly install/configure Maven
  • In Job configuration, for Maven Version, you must select Default. This is the setting that uses the version that's installed locally on the node

If you want to have Jenkins install Maven for you

  • You must go to Jenkins Global Tool Configuration, and configure a Maven version with automatic installer (from the web).
  • In Job configuration, for Maven Version, you must select that particular version that you've just configured.
Vikash
  • 2,046
  • 3
  • 23
  • 30
Slav
  • 27,057
  • 11
  • 80
  • 104
  • 2
    Best explanation I've found for this concept. Clear and to the point. Thanks for explaining the need to update the Global config _and_ also selecting the configured maven in the job config. – Michael J Jun 30 '17 at 07:20
  • how do you specify the version of maven in job dsl files? – Muatik Jan 31 '18 at 16:08
  • 1
    Thats it... "In Job configuration, for Maven Version, you must select that particular version that you've just configured." – Hassan Jamil Feb 12 '19 at 07:29
45

If you are just looking for simplest solution then you should go to global jenkins configuration

http://localhost:32773/configureTools/

And configure maven like that

enter image description here

Then you have to go to your project. Inside settings you have build. Chose maven which you have created a minute ago.

enter image description here

Marcin Szymczak
  • 11,199
  • 5
  • 55
  • 63
1

I had the same problem and i installed maven in Jenkins Server and issue was fixed.

sudo yum install maven
K M Dilshan Udara
  • 1,025
  • 1
  • 11
  • 15
0

After configured Maven in globally Created Build a maven2/3 project job instead of Build a free-style software project and post build sonar works fine!

Radhakrishnan
  • 564
  • 4
  • 6
0

I had the same problem I added maven in my global tool configuration but not worked. the reason is my instance is a enter image description herenewly created one. I installed maven after that it worked.

Rajitha Bhanuka
  • 714
  • 10
  • 11
0

I had the same problem on colab and i installed mav in Jenkins Server and issue was fixed.

!sudo apt install maven

import imagej;
ij = imagej.init(); 
print(ij.getVersion())
Bharath Kumar
  • 893
  • 9
  • 8
0

I had the same problem, but my solution turned out to be very specific. I post it anyway, someone may have the same problem.

I had installed a new JDK before this happened. Even though Maven declared it uses the right Java version (as displayed from mvn -version), there seemed a problem with the installation either not being fully completed or Maven not having registered the new version correctly. I really don't know, but after trying to figure out for two hours, I decided to restart Ubuntu, and after that, the problem was gone.

not2savvy
  • 2,902
  • 3
  • 22
  • 37
0

If you are using slave node to run the job and get same error while running job then chances are there that you have not configured tools location in your slave node configuration in Jenkins.

Under Dashboard -> Nodes -> Slave name

In Node Properties section -> Check Tool Locations check box and add maven as tool with actual installation path on slave machine(see attached image). enter image description here Rerun your job once it is configured and error should go away.

Prakash Boda
  • 808
  • 7
  • 21