在运行Maven Command Jenkins时拒绝允许的权限



我在jenkins的pom.xml上运行maven clean test时面临拒绝的问题。任何建议

Building in workspace /var/lib/jenkins/workspace/jenkins
[jenkins] $ /usr/share/maven/bin/mvn -f /home/tes/pom.xml clean test
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project  (/home/tes/pom.xml) has 1 error
[ERROR]     Non-readable POM /home/tes/pom.xml: /home/tes/pom.xml (Permission denied)
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

只需授予所有访问pom.xml文件的访问:

chmod +r /home/tes/pom.xml

主持人删除了我以前的答案;我知道它已经过去了一篇文章以来已经过去了一段时间,但是我完全呆在同一位置。我坚持要补充所有答案,因为我发现了问题上的问题,结果与本案中报告的结果相同。

我想评论,就我而言,原因是我没有JDK,而只是在全局工具配置的Java_home中配置了JRE>jdk>JDK安装。事实上,詹金斯警告您,这条路并不指向包含JDK的东西。

某些插件(例如Maven Integration或Docker Pipeline)需要JDK,作为Jenkins Documentation的Java需求部分。因此,必须检查一下,因为它出奇地导致了奇怪的错误:
> git rev-parse refs/remotes/origin/celsus_0-1-0^{commit} # timeout=10
Checking out Revision 0c533cf2327a416a254afa2348abafe7790ba67f (refs/remotes/origin/celsus_0-1-0)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 0c533cf2327a416a254afa2348abafe7790ba67f # timeout=10
Commit message: "first embrio of container image"
 > git rev-list --no-walk 0c533cf2327a416a254afa2348abafe7790ba67f # timeout=10
Parsing POMs
Established TCP socket on 40251
[build] $ /usr/lib/jvm/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.13.jar:/usr/share/maven/boot/plexus-classworlds-2.x.jar:/usr/share/maven/conf/logging jenkins.maven3.agent.Maven35Main /usr/share/maven /var/cache/jenkins/war/WEB-INF/lib/remoting-4.5.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 40251
ERROR: Failed to parse POMs
java.io.IOException: Cannot run program "/usr/lib/jvm/bin/java" (in directory "/var/lib/jenkins/workspace/build"): error=2, No such file or directory
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
    at hudson.Proc$LocalProc.<init>(Proc.java:252)
    at hudson.Proc$LocalProc.<init>(Proc.java:221)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
    at hudson.Launcher$ProcStarter.start(Launcher.java:508)
    at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:280)
    at hudson.maven.ProcessCache.get(ProcessCache.java:236)
    at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:802)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:514)
    at hudson.model.Run.execute(Run.java:1907)
    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.base/java.lang.ProcessImpl.forkAndExec(Native Method)
    at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
    at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
    ... 13 more
Finished: FAILURE

类似的情况,正如提出的解决方案的不同性质所指出的那样。我想引起注意,这些错误与权限有关,或者对POM的解析可能会隐藏真正的根本原因,并且错误消息并不总是那么明确和清晰。

希望它可以帮助其他人遇到同一问题。

我为Jenkins安装了Maven插件,并在root pom.xml中提供了POM.xml的完全合格的路径,并修复了问题

我认为发生这种情况的原因是maven有权运行pom.xml IE。MVN命令可以通过终端运行,但不能通过Jenkins运行。因此,我们需要将当前用户添加到Jenkins才能工作。

遵循此博客文章。它对我有用:

blogpost

最新更新