无法运行程序“mvn”error = 2,没有这样的文件或目录

时间:2014-11-13 10:43:27

标签: java linux jenkins continuous-integration ubuntu-14.04

我正在使用我的Ubuntu 14.04 LTS进行构建但是我得到了以下内容:

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

我假设这是由一些linux安全功能引起的,它阻止在没有正确权限的情况下创建/ var / lib / jenkins / workspace / videovixx 我可能没有。这是问题,我该如何解决?

7 个答案:

答案 0 :(得分:42)

这里有很多东西。

您要么在作业配置中没有选择Maven版本。 或者您没有配置Jenkins来安装Maven版本。 或者您希望在Slave上使用本地安装的Maven,但它没有为jenkins用户配置。

由于我不知道您配置了什么(或者没有配置)以及您希望使用什么,我无法直接回答,但我可以解释它是如何工作的

如果要在主/从

上使用本地安装的Maven
  • 您必须在本地安装Maven
  • 您必须能够使用jenkins用户启动它
    1. 执行sudo jenkins,然后在您的从属服务器上执行mvn以验证jenkins用户是否可以运行mvn
    2. 如果失败,则需要正确安装/配置Maven
  • 在作业配置中,对于Maven版本,您必须选择Default。这是使用在节点
  • 上本地安装的版本的设置

如果你想让Jenkins为你安装Maven

  • 您必须访问Jenkins全局配置,并使用自动安装程序(来自网络)配置Maven版本。
  • 在作业配置中,对于Maven版本,您必须选择 您刚刚配置的特定版本。

答案 1 :(得分:23)

如果您只是寻找最简单的解决方案,那么您应该去全球jenkins配置

http://localhost:32773/configureTools/

并像那样配置maven

enter image description here

然后你必须去你的项目。您已构建内部设置。选择你在一分钟前创建的maven。

enter image description here

答案 2 :(得分:1)

我遇到了同样的问题,并且在Jenkins Server中安装了maven,问题已得到解决。

sudo yum install maven

答案 3 :(得分:0)

全局配置Maven后 创建构建maven2 / 3项目作业,而不是B 使用自由式软件项目,并且构建声纳工作正常!

答案 4 :(得分:0)

我遇到了同样的问题,我在全局工具配置中添加了maven,但是没有用。原因是我的实例是enter image description here新创建的实例。我安装了maven之后就可以了。

答案 5 :(得分:0)

我在colab上遇到了同样的问题,并且在Jenkins Server中安装了mav,问题已解决。

!sudo apt install maven

import imagej;
ij = imagej.init(); 
print(ij.getVersion())

答案 6 :(得分:0)

我遇到了同样的问题,但我的解决方案非常具体。反正我发了,可能有人遇到同样的问题。

在这发生之前我已经安装了一个新的 JDK。尽管 Maven 声明它使用了正确的 Java 版本(如 mvn -version 中所示),但安装似乎存在问题,要么没有完全完成,要么 Maven 没有正确注册新版本。我真的不知道,但是想了两个小时后,我决定重启Ubuntu,然后问题就消失了。