Jenkins 错误:“无法删除文件”调用 Ant 时

发布于 2024-12-07 22:10:49 字数 1587 浏览 0 评论 0原文

我在 Ubuntu 11.04 上运行 Jenkins 1.433,以便执行包含 Ant 任务的构建。我的 Ant 任务的 clean 部分(从之前的构建中删除 build 目录)在从终端运行 sudo Ant 时可以工作,但会失败来自 Jenkins 的内容如下:

BUILD FAILED
/var/lib/jenkins/workspace/AomaTests/build.xml:47: Unable to delete directory /var/lib/jenkins/workspace/AomaTests/build

Jenkins 引用的 Ant 安装是从命令行 (usr/bin/ant) 运行的安装,并且 Jenkins 项目专门指向此实例(而不是 <代码>默认)。考虑到这是一个权限问题,我尝试了以下操作:

  • chown -R相应的build目录,将其所有者设置为jenkins
  • 在目录上执行chmod 777
  • 暂时允许 jenkins 用户名无需密码即可运行内容(通过使用 jenkins ALL = NOPASSWD:ALL 行编辑 sudoers 文件) 。

这些方法都不起作用。我应该通过不同的用户运行 ant,还是通过 Jenkins 传递一些属性?

更新:ps -ef | 的输出grep "jenkins" 是:

jenkins   1647     1  0 12:28 ?        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 -jar /usr/share/jenkins/jenkins.war --webroot=/var/run/jenkins/war --httpPort=8080 --ajp13Port=-1
jenkins   1660  1647  7 12:28 ?        00:00:13 /usr/bin/java -jar /usr/share/jenkins/jenkins.war --webroot=/var/run/jenkins/war --httpPort=8080 --ajp13Port=-1
mattcarp  2393  2229  0 12:31 pts/0    00:00:00 grep --color=auto jenkins

在无法删除的目录上运行 ls -l (当从 Jenkins 运行时)显示:

drwxr-xr-x 2 jenkins root 4096 2011-10-03 14:49 build

非常感谢您的任何建议!

I'm running Jenkins 1.433 on Ubuntu 11.04 in order to perform a build which includes an Ant task. The clean portion of my Ant task, which deletes the build directory from prior builds, will work when running sudo Ant from the terminal, but fails from Jenkins with the following:

BUILD FAILED
/var/lib/jenkins/workspace/AomaTests/build.xml:47: Unable to delete directory /var/lib/jenkins/workspace/AomaTests/build

The Ant install referenced by Jenkins is the one which works from the command line (usr/bin/ant), and the Jenkins project specifically points to this instance (and not to Default). Figuring this was a permissions problem, I tried the following:

  • chown -R the appropriate build directory, setting its owner to jenkins.
  • Doing a chmod 777 on the directory.
  • Temporarily allowing the jenkins username the ability to run things without a pasword (via editing the sudoers file with the line jenkins ALL = NOPASSWD:ALL).

None of these approaches workd. Should I be running ant via a different user, or perhaps passing it some properties via Jenkins?

Update: The output of ps -ef | grep "jenkins" is:

jenkins   1647     1  0 12:28 ?        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 -jar /usr/share/jenkins/jenkins.war --webroot=/var/run/jenkins/war --httpPort=8080 --ajp13Port=-1
jenkins   1660  1647  7 12:28 ?        00:00:13 /usr/bin/java -jar /usr/share/jenkins/jenkins.war --webroot=/var/run/jenkins/war --httpPort=8080 --ajp13Port=-1
mattcarp  2393  2229  0 12:31 pts/0    00:00:00 grep --color=auto jenkins

Running ls -l on the directory that fails to be deleted (when run from Jenkins) shows:

drwxr-xr-x 2 jenkins root 4096 2011-10-03 14:49 build

Many thanks for any advice!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

明媚如初 2024-12-14 22:10:49

事实证明,所需要做的就是将目录的所有者设置为jenkins

哇——要得到如此简单的答案还有很长的路要走!

As it turns out, all that was required was to set the parent directory's owner to jenkins.

Wow - that was a long way to go for such a simple answer!

心碎无痕… 2024-12-14 22:10:49

谁在运行詹金斯?这就是问题所在。有一些用户正在运行 Java 进程,该进程正在运行 Jenkins 服务器。您需要找到该用户。试试这个:

 $ ps -ef | grep "jenkins"

看看你会得到什么。

知道你的名字是 Matt 并且我看到无法删除的文件位于 /home/mattcarp 目录中,这告诉我发生了一些奇怪的事情。我的第一个猜测是 Jenkins 不是由用户 mattcarp 执行的。

  • 詹金斯是如何安装的?它是否作为自己的用户安装在自己的目录中?通常就是这样完成的。例如,您将 Jenkins 安装在 /home/jenkins 中,所有作业都在 /home/jenkins/jobs 中,并且 for 作业 foo 的工作空间 位于 /home/jenkins/jobs/foo/workspace 中。为什么 Jenkins 会查看您的 $HOME 目录?
  • 您的 Ant build.xml 文件如何工作?您是否在 build.xml 文件中对目录 /home/mattcarp/workspace/... 进行了硬编码?如果是,您需要重做 build.xml 以使用其当前目录树,而不是对其进行硬编码。

Who is running Jenkins? That's the question. There is some user that's running the Java process that's running the Jenkins server. You need to find that user. Try this:

 $ ps -ef | grep "jenkins"

and see what you get.

Knowing that your name is Matt and I see that the file that can't be deleted is in the /home/mattcarp directory, something tells me there's something screwy going on. My first guess is that Jenkins is not being executed by the user mattcarp.

  • How is Jenkins installed? Is it installed as its own user in its own directory? That's usually how it is done. For example, you install Jenkins in /home/jenkins, and all the jobs are in /home/jenkins/jobs, and the workspace for a for job foo is in /home/jenkins/jobs/foo/workspace. Why is Jenkins looking at your $HOME directory?
  • How does your Ant build.xml file work? Are you hard coding the directory /home/mattcarp/workspace/... in the build.xml file? If you are, you need to redo your build.xml to use its current directory tree and not hard code it.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文