运行顶级 Maven 目标时
test
我收到以下错误:
FATAL: command execution failed
java.io.IOException: Cannot run program "mvn" (in directory "/var/lib/jenkins /jobs/selenium/workspace"): java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:475)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:709)
at hudson.Launcher$ProcStarter.start(Launcher.java:338)
at hudson.Launcher$ProcStarter.join(Launcher.java:345)
at hudson.tasks.Maven.perform(Maven.java:263)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:717)
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:499)
at hudson.model.Run.execute(Run.java:1502)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:236)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:164)
at java.lang.ProcessImpl.start(ProcessImpl.java:81)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:468)
... 15 more
Build step 'Invoke top-level Maven targets' marked build as failure
这似乎是关于 maven 路径的问题,但我已经在我的主机上设置了 maven 路径。M2_HOME、M2 和 PATH 都是正确的。我知道它们是正确的,因为我可以从命令行运行 maven 命令。当我尝试在 jenkins 中调用 maven 命令时,虽然我得到了错误。所以我进入Jenkins->Manage Jenkins->Configure System
并点击了 Maven 安装...我检查了
Install automatically
Version 2.2.1
我单击保存并尝试再次运行我的项目,但出现相同的错误。当我做 mvn -version 我得到 2.2.1 所以这应该是正确的。从配置系统页面我也尝试过
Name default
MAVEN_HOME /usr/local/apache-maven/apache-maven-2.2.1
有任何想法吗?