I'm getting this error when attempting a Maven build in Jenkins,
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
I have follow the links and they own by root but with 777 permissions so enable for everyone to follow the link, the real file is read for everyone.. so not sure why is this happening.
any tips?
Best Answer
Do you run Jenkins manually or via service?
It's not recommended to run it manually via
java -jar /usr/share/jenkins/jenkins.war
but withservice jenkins start|stop
.When you manually start, it'll change owner to user which started
jenkins.war
viajava
, service runs under user:groupjenkins:jenkins
.Default path for service Jenkins (Debian/Ubuntu) should be
/var/lib/jenkins/jobs/<ProjectName>/workspace
and everything inside/var/lib/jenkins/
must be owned by userjenkins
and groupjenkins
:Also check if you have a properly installed and configured JDK inside your Jenkins project.