8

I'm setting up a Jenkins system at MacOSX Server for an automatically build after a svn checkin. But when the build is starting I get these java error at the console output. Does anyone have experience with Jenkins and these error?

Gestartet durch Benutzer anonymous
[EnvInject] - Loading node environment variables.
Baue in Workspace /Users/Shared/Jenkins/Home/jobs/myProject/workspace
Cleaning local Directory .
java.nio.file.AccessDeniedException: /Users/Shared/Jenkins/Home/jobs/my Project/workspace/./.svn/pristine/04/040d4cd4de48d844246c38e096a78718879bfafb.svn-base
 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:1126)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:497)
 at hudson.Util.deleteFile(Util.java:255)
 at hudson.Util.deleteRecursive(Util.java:318)
 at hudson.Util.deleteContentsRecursive(Util.java:220)
 at hudson.Util.deleteRecursive(Util.java:309)
 at hudson.Util.deleteContentsRecursive(Util.java:220)
 at hudson.Util.deleteRecursive(Util.java:309)
 at hudson.Util.deleteContentsRecursive(Util.java:220)
 at hudson.Util.deleteRecursive(Util.java:309)
 at hudson.Util.deleteContentsRecursive(Util.java:220)
 at hudson.scm.subversion.CheckoutUpdater$1.perform(CheckoutUpdater.java:81)
 at hudson.scm.subversion.WorkspaceUpdater$UpdateTask.delegateTo(WorkspaceUpdater.java:162)
 at hudson.scm.SubversionSCM$CheckOutTask.perform(SubversionSCM.java:988)
 at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:969)
 at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:945)
 at hudson.FilePath.act(FilePath.java:990)
 at hudson.FilePath.act(FilePath.java:968)
 at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:894)
 at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:830)
 at hudson.scm.SCM.checkout(SCM.java:485)
 at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
 at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
 at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
 at hudson.model.Run.execute(Run.java:1738)
 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
 at hudson.model.ResourceController.execute(ResourceController.java:98)
 at hudson.model.Executor.run(Executor.java:410)
Sending e-mails to: m...
Finished: FAILURE
marcelZ
  • 81
  • 1
  • 1
  • 3
  • The file is locked by another process. Might be you have that file open in some program (SVN-client?) or it's a directory that's open in Explorer or it is the working directory of a command shell. – Axel Jan 26 '16 at 10:35

4 Answers4

9

This problem is occurring because you don't have permission to execute the job on the Jenkins jobs dir (in your case /Users/Shared/Jenkins/Home/jobs) or you don't have permission on the jenkins dir /var/lib/jenkins/.

I got the same problem when I tried to copy the jobs dir from a server to another.

To solve this we need to change the owner of jobs to the jenkins user:

sudo chown -R jenkins:jenkins jobs

If this does no solve, the the problem can be with the permission of your var/lib/jenkins dir:

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

This will solve your problem.

ps. Maybe you will need to restart your Jenkins application

valdeci
  • 13,962
  • 6
  • 55
  • 80
  • 1
    On ubuntu following command fixed the issue: `sudo chown -R jenkins:jenkins /var/lib/jenkins/`, and a restart of jenkins is needed. – Eric Oct 27 '19 at 07:26
2

Seems like the os user which is running jenkins has no write privileges for either the complete workspace directory or some of the files in the workspace directory.

Julien Charon
  • 600
  • 1
  • 7
  • 21
0

If you have encountred this issue usually it's related to the user running the jenkins process and sometimes that user wouldn't be able to do some actions or access files so you will need to provide him with certain permissions as said above you can use chown or chmod like so:

# Change ownership to a whole directory
chmod -R user:group /path/to/dir
# Change ownership to a single file
chmod user:group /path/to/file
# Careful with the value after chmod
# You will need to only give what's needed
# Change ownership to a whole directory
chmod 744 -R /path/to/dir
# Change ownership to a single file
chmod 744 /path/to/file

An in your case since you're dealing with jenkins usually you can either find the directory of jenkins data under:

  • Default path: /var/lib/jenkins/
  • Env var (usually defined like that in a docker container): JENKINS_HOME=/var/jenkins_home
  • In case you have access to the configuration page, you can find it on the header as Home directory : http://localhost:8080/configure
Affes Salem
  • 1,303
  • 10
  • 26
-2

You need to modify the permission for jenkins user so that you can run the shell commands. Make root user of your machine as default user of jenkins, will slove your problem.

Following process is for CentOS

  1. Open up the this script (using VIM or other editor):

vim /etc/sysconfig/jenkins

  1. Find this $JENKINS_USER and change to “root”:

$JENKINS_USER="root"

  1. Then change the ownership of Jenkins home, webroot and logs:
chown -R root:root /var/lib/jenkins
chown -R root:root /var/cache/jenkins
chown -R root:root /var/log/jenkins
  1. Restart Jenkins and check the user has been changed:
service jenkins restart
ps -ef | grep jenkins
cnnr
  • 1,267
  • 4
  • 18
  • 23
Praveen Muniraj
  • 103
  • 1
  • 4