[英]Cannot run program "mvn" error=2, No such file or directory
I'm doing a build on my Ubuntu 14.04 LTS but I'm getting the following:我正在我的 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
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.我假设这是由一些 linux 安全功能引起的,该功能阻止 /var/lib/jenkins/workspace/videovixx 在没有我可能没有的正确权限的情况下创建。 Is this the problem and how do I solve it?
这是问题吗?我该如何解决?
There are multiple things here.这里有很多东西。
You either didn't select Maven version in Job configuration.您要么没有在作业配置中选择 Maven 版本。 Or you didn't configure Jenkins to install a Maven version.
或者你没有配置 Jenkins 来安装 Maven 版本。 Or you expected to use locally installed Maven on the Slave, but it's not configured for
jenkins
user.或者您希望在 Slave 上使用本地安装的 Maven,但它没有为
jenkins
用户配置。
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.由于我不知道您已配置(或未配置)什么以及您希望使用什么,我无法直接回答,但我可以解释它是如何工作的。
jenkins
userjenkins
用户启动它
sudo jenkins
, and then execute mvn
on your Slave to verify that jenkins
user can run mvn
sudo jenkins
,然后在你的 Slave 上执行mvn
以验证jenkins
用户可以运行mvn
Default
.Default
。 This is the setting that uses the version that's installed locally on the nodeIf you are just looking for simplest solution then you should go to global jenkins configuration如果您只是在寻找最简单的解决方案,那么您应该去全局 jenkins 配置
http://localhost:32773/configureTools/
And configure maven like that并像这样配置maven
Then you have to go to your project.然后你必须去你的项目。 Inside settings you have build.
您已构建的内部设置。 Chose maven which you have created a minute ago.
选择您在一分钟前创建的 maven。
我遇到了同样的问题,我在 Jenkins Server 中安装了 maven,问题得到了解决。
sudo yum install maven
在全局配置 Maven 后,创建构建一个 maven2/3 项目作业,而不是构建一个自由样式的软件项目,然后构建声纳工作正常!
I had the same problem I added maven in my global tool configuration but not worked.我遇到了同样的问题,我在全局工具配置中添加了 maven,但没有奏效。 the reason is my instance is a enter image description here newly created one.
原因是我的实例是在此处新创建的输入图像描述。 I installed maven after that it worked.
之后我安装了maven,它起作用了。
I had the same problem on colab and i installed mav in Jenkins Server and issue was fixed.我在 colab 上遇到了同样的问题,我在 Jenkins Server 中安装了 mav 并修复了问题。
!sudo apt install maven
import imagej;
ij = imagej.init();
print(ij.getVersion())
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.在这发生之前,我已经安装了一个新的 JDK。 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.即使 Maven 声明它使用正确的 Java 版本(从
mvn -version
显示),安装似乎也存在问题,要么没有完全完成,要么 Maven 没有正确注册新版本。 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.我真的不知道,但是在尝试了两个小时之后,我决定重新启动 Ubuntu,然后问题就消失了。
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.如果您使用从节点运行作业并在运行作业时遇到相同的错误,那么您可能没有在 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).在节点属性部分 - > 检查工具位置复选框并添加 maven 作为工具,并在从机上使用实际安装路径(参见附图)。
Rerun your job once it is configured and error should go away.
配置完成后重新运行您的作业,错误应该会消失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.