Jenkins构建失败,无法解析pom

时间:2020-04-17 16:34:57

标签: java jenkins

我有一个詹金斯(Jenkins)maven作业,运行该作业时出现以下错误。

Started by user admin
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/My First Maven Job
No credentials specified
 > /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://github.com/yankils/hello-world.git # timeout=10
Fetching upstream changes from https://github.com/yankils/hello-world.git
 > /usr/bin/git --version # timeout=10
 > /usr/bin/git fetch --tags --force --progress -- https://github.com/yankils/hello-world.git +refs/heads/*:refs/remotes/origin/* # 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 de043c505e7adab1f892498ca231280298fc2674 (refs/remotes/origin/master)
 > /usr/bin/git config core.sparsecheckout # timeout=10
 > /usr/bin/git checkout -f de043c505e7adab1f892498ca231280298fc2674 # timeout=10
Commit message: "Update Dockerfile"
 > /usr/bin/git rev-list --no-walk de043c505e7adab1f892498ca231280298fc2674 # timeout=10
Parsing POMs
Established TCP socket on 34699
[My First Maven Job] $ " /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-1.el8_0.x86_64/bin/java" -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.13.jar:/opt/maven/apache-maven-3.6.3/boot/plexus-classworlds-2.6.0.jar:/opt/maven/apache-maven-3.6.3/conf/logging jenkins.maven3.agent.Maven35Main /opt/maven/apache-maven-3.6.3 /var/cache/jenkins/war/WEB-INF/lib/remoting-4.2.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.13.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.13.jar 34699
ERROR: Failed to parse POMs
java.io.IOException: Cannot run program " /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-1.el8_0.x86_64/bin/java" (in directory "/var/lib/jenkins/workspace/My First Maven Job"): error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at hudson.Proc$LocalProc.<init>(Proc.java:252)
    at hudson.Proc$LocalProc.<init>(Proc.java:221)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:936)
    at hudson.Launcher$ProcStarter.start(Launcher.java:454)
    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:1856)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:428)
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
Finished: FAILURE

我可以看到它正在查看/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-1.el8_0.x86_64/bin,因为我有openjdk /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.amzn2.0.1.x86_64/jre

如何在Jenkins服务器上解决此问题?

1 个答案:

答案 0 :(得分:0)

将JAVA_HOME设置为/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.amzn2.0.1.x86_64 与/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-1.el8_0.x86_64