FATAL: command execution failed java.io.IOException: error=2, No such file or directory

问题说明:使用Jenkins热部署时遇到的问题 :

[stla-main] $ mvn -s /opt/maven/apache-maven-3.6.3/conf/settings.xml -gs /opt/maven/apache-maven-3.6.3/conf/settings.xml
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.<init>(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/lib/jenkins/workspace/stla-main"): error=2, No such file or directory
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
	at hudson.Proc$LocalProc.<init>(Proc.java:250)
	at hudson.Proc$LocalProc.<init>(Proc.java:219)
	at hudson.Launcher$LocalLauncher.launch(Launcher.java:937)
	at hudson.Launcher$ProcStarter.start(Launcher.java:455)
	at hudson.Launcher$ProcStarter.join(Launcher.java:466)
	at hudson.tasks.Maven.perform(Maven.java:368)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
	at hudson.model.Build$BuildExecution.build(Build.java:206)
	at hudson.model.Build$BuildExecution.doRun(Build.java:163)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
	at hudson.model.Run.execute(Run.java:1853)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:427)
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

解决方案:

  1. 找到全局工具配置FATAL: command execution failed java.io.IOException: error=2, No such file or directory_第1张图片
  2. 向下拉:找到maven
    FATAL: command execution failed java.io.IOException: error=2, No such file or directory_第2张图片
  3. 配置maven:MAVEN_HOME可以在服务器上执行 mvn -v 看到
    FATAL: command execution failed java.io.IOException: error=2, No such file or directory_第3张图片
  4. 保存,然后在你Jenkins的工程上点击配置
    FATAL: command execution failed java.io.IOException: error=2, No such file or directory_第4张图片
    点击你配置的maven就ok了
    FATAL: command execution failed java.io.IOException: error=2, No such file or directory_第5张图片

你可能感兴趣的:(question)