jenkinsmaven java 7权限问题

我在尝试在Jenkins中构buildMaven时遇到了这个错误,

Building in workspace /var/lib/jenkins/workspace/xxxxprojectnamedeletedforprivacyxxxx java.nio.file.AccessDeniedException: /usr/share/maven/lib/maven-settings-3.x.jar at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:244) at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103) at java.nio.file.Files.delete(Files.java:1079) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at hudson.Util.deleteFile(Util.java:247) at hudson.FilePath.deleteRecursive(FilePath.java:1202) at hudson.FilePath.deleteContentsRecursive(FilePath.java:1211) at hudson.FilePath.deleteRecursive(FilePath.java:1193) at hudson.FilePath.deleteContentsRecursive(FilePath.java:1211) at hudson.FilePath.deleteRecursive(FilePath.java:1193) at hudson.FilePath.access$1000(FilePath.java:191) at hudson.FilePath$14.invoke(FilePath.java:1172) at hudson.FilePath$14.invoke(FilePath.java:1169) at hudson.FilePath.act(FilePath.java:989) at hudson.FilePath.act(FilePath.java:967) at hudson.FilePath.deleteRecursive(FilePath.java:1169) at hudson.tools.JDKInstaller.performInstallation(JDKInstaller.java:130) at hudson.tools.InstallerTranslator.getToolHome(InstallerTranslator.java:68) at hudson.tools.ToolLocationNodeProperty.getToolHome(ToolLocationNodeProperty.java:107) at hudson.tools.ToolInstallation.translateFor(ToolInstallation.java:205) at hudson.model.JDK.forNode(JDK.java:130) at hudson.model.AbstractProject.getEnvironment(AbstractProject.java:351) at hudson.model.Run.getEnvironment(Run.java:2219) at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:917) at hudson.maven.AbstractMavenBuild.getEnvironment(AbstractMavenBuild.java:56) at hudson.maven.MavenModuleSetBuild.getEnvironment(MavenModuleSetBuild.java:167) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:977) at hudson.scm.SCM.checkout(SCM.java:484) at hudson.model.AbstractProject.checkout(AbstractProject.java:1270) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:609) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:531) at hudson.model.Run.execute(Run.java:1718) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531) at hudson.model.ResourceController.execute(ResourceController.java:89) at hudson.model.Executor.run(Executor.java:240) Finished: FAILURE 

我已经按照链接,他们自己的根,但拥有777权限,以便每个人都可以按照链接,真正的文件是为大家阅读..所以不知道为什么会发生这种情况。 有小费吗?

你手动或通过服务运行jenkins? 不build议通过java -jar /usr/share/jenkins/jenkins.war手动运行它,但服务jenkins start | stop 。 当你手动启动时,它会将所有者更改为通过java启动jenkins.war的用户,服务在用户:jenkins组下运行。

服务jenkins(Debian / Ubuntu)的默认path应该是/ var / lib / jenkins / jobs / ProjectName / workspace和/ var / lib / jenkins /里面的所有东西都必须拥有用户jenkins和jenkins( chown -R jenkins:jenkins / var / lib / jenkins /

还要检查你的Jenkins项目中是否安装了正确的JDK。

看起来像你试图删除一个文件作为你的构build的一部分:

at java.nio.file.Files.delete(Files.java:1079)

您将需要相应地调整您的权限以允许写入权限以及父path和相关文件。 就我个人而言,我build议你将所有者设置为Jenkins运行的同一用户,并使用chmod -R u+w,go-w <directory>将权限设置为仅允许该用户进行修改。

如果我不得不猜测,看起来maven很可能是由root安装的,因此由root拥有。

如果jenkins是通过任何软件包pipe理器安装的,很可能是作为“jenkins”用户运行,无法访问该maven安装。

只是一个想法 – 为什么不configurationjenkins来安装/pipe理你想使用的maven版本?

Jenkins会把你正在寻找的Maven版本放在一个可以访问的位置(基于/ toolspath)。