Jenkins构建的java.nio.file.AccessDeniedException

时间:2016-01-26 10:28:24

标签: java macos svn jenkins access-denied

我在MacOSX Server上设置一个Jenkins系统,用于在svn签入后自动构建。但是当构建开始时,我在控制台输出中得到这些java错误。有没有人有詹金斯的经验和这些错误?

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

3 个答案:

答案 0 :(得分:0)

似乎运行jenkins的os用户对完整工作区目录或工作区目录中的某些文件没有写权限。

答案 1 :(得分:0)

之所以出现此问题,是因为您没有在Jenkins作业目录(在您的情况下为/Users/Shared/Jenkins/Home/jobs)上执行作业的权限。

当我尝试将作业目录从一台服务器复制到另一个服务器时,我遇到了同样的问题。

要解决此问题,我们需要将jobs的所有者更改为jenkins用户:

sudo chown -R jenkins:jenkins jobs

这将解决您的问题。

答案 2 :(得分:0)

您需要修改jenkins用户的权限,以便您可以运行shell命令。 将您计算机的root用户设置为jenkins的默认用户,将解决您的问题。

以下过程适用于CentOS

  1. 打开此脚本(使用VIM或其他编辑器):

vim /etc/sysconfig/jenkins

  1. 找到此$ JENKINS_USER并更改为“ root”:

$JENKINS_USER="root"

  1. 然后更改Jenkins住宅,webroot和日志的所有权:
chown -R root:root /var/lib/jenkins
chown -R root:root /var/cache/jenkins
chown -R root:root /var/log/jenkins
  1. 重新启动Jenkins并检查用户是否已更改:
service jenkins restart
ps -ef | grep jenkins