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?

4 Answers 4


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 with service jenkins start|stop.

When you manually start, it'll change owner to user which started jenkins.war via java, service runs under user:group jenkins: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 user jenkins and group jenkins:

chown -R jenkins:jenkins /var/lib/jenkins/

Also check if you have a properly installed and configured JDK inside your Jenkins project.


Seems like you're trying to delete a file as part of your build:

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

You will need to adjust your permissions accordingly to allow for write access as well on the parent path and the file(s) in question. Personally I would recommend you set the owner to the same user that Jenkins runs as and use chmod -R u+w,go-w <directory> to set the permissions to only allow that user to make modifications.

  • Hello, and thanks for your help. this is on a ubuntu 14.04 so runs as user jenkins. so when you say <directory> you mean the jenkins workspace directory for the project? Jan 29, 2015 at 18:32
  • In the general case yes, in a more broad case you probably want to do that on the workspace directory itself (the parent of the project directories)
    – Foosh
    Jan 29, 2015 at 18:35
  • Thanks. I have to change the location of the workspace dir anyways since now is on the main HD, going to mount another HD and make that the workspace since that can get very big fast.. :) I will do the change and make sure the user is jenkins and group jenkins and will report back. hope this will fix the build error Jan 29, 2015 at 18:57
  • hmm no luck. Building in workspace /workspace/workspace/mydir this have jenkins:jekins permissions all the way to the top dir.. ls -alh /workspace/ total 4.0K drwxr-xr-x 4 jenkins jenkins 34 Jan 29 19:00 . drwxr-xr-x 24 root root 4.0K Jan 29 18:34 .. drwxr-xr-x 3 jenkins jenkins 35 Jan 29 18:56 workspace Jan 29, 2015 at 19:03
  • add I went into the directory and is empty... so aparently it did not write anything.. as you can see jenkins is running as user jenkins jenkins 1122 1 0 18:34 ? 00:00:00 /usr/bin/daemon --name=jenkins --inherit --env=JENKINS_HOME=/var/lib/jenkins --output=/var/log/jenkins/jenkins.log --pidfile=/var/run/jenkins/jenkins.pid -- /usr/bin/java -Djava.awt.headless=true -jar /usr/share/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080 Jan 29, 2015 at 19:05

If I had to guess, it looks like maven was installed likely by root, and thereby owned by root.

If jenkins was installed via any package manager, likely it is running as a "jenkins" user which won't have access to that maven installation.

Just a thought - why not configure jenkins to install/manage the version of maven you'd like to use?

Jenkins will put the maven version you're looking for in a location (based off of the /tools path) which it will have access to.


I created a folder in /opt and set permissions, but this path must be configured in your Jenkins:

sudo mkdir /opt/deploy_jenkins
sudo chmod -R a+rw deploy_jenkins/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .