昨天更新JDK版本后,修改了JAVA_HOME环境变量值。导致群里一直收到Jenkins任务构建失败的消息。差点被同事们拉出去祭器旗[酷拽]!
报错信息
ERROR: Failed to parse POMs
java.io.IOException: Cannot run program "java" (in directory "/home/workspace/jenkins/workspace/test-xxx"): 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.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:280)
at hudson.maven.ProcessCache.get(ProcessCache.java:236)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:804)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1818)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
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:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 12 more
SSH: Current build result is [FAILURE], not going to run.
Finished: FAILURE
解决办法
不要被报错信息所误导,并不是不存在这个目录。真正原因是变更Java安装目录后Jenkins没有同步更新。有如下两种解决办法
一、增加软连接
Jenkins默认执行/usr/bin/java(不同版本可能不一样),可以把边变更后的java安装目录软连接到此,操作,命令:
ln -s /usr/java/jdk1.8.0_201/bin/java /usr/bin/java
/usr/java/jdk1.8.0_201需要替换成自己的。
二、配置能新的java安装目录
至此,就能正常构建啦