Jenkins 错误:“无法删除文件”调用 Ant 时
我在 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 appropriatebuild
directory, setting its owner tojenkins
.- Doing a
chmod 777
on the directory. - Temporarily allowing the
jenkins
username the ability to run things without a pasword (via editing thesudoers
file with the linejenkins 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实证明,所需要做的就是将父目录的所有者设置为
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!
谁在运行詹金斯?这就是问题所在。有一些用户正在运行 Java 进程,该进程正在运行 Jenkins 服务器。您需要找到该用户。试试这个:
看看你会得到什么。
知道你的名字是 Matt 并且我看到无法删除的文件位于 /home/mattcarp 目录中,这告诉我发生了一些奇怪的事情。我的第一个猜测是 Jenkins 不是由用户 mattcarp 执行的。
/home/jenkins
中,所有作业都在/home/jenkins/jobs
中,并且 for 作业foo 的工作空间
位于/home/jenkins/jobs/foo/workspace
中。为什么 Jenkins 会查看您的$HOME
目录?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:
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
./home/jenkins
, and all the jobs are in/home/jenkins/jobs
, and the workspace for a for jobfoo
is in/home/jenkins/jobs/foo/workspace
. Why is Jenkins looking at your$HOME
directory?build.xml
file work? Are you hard coding the directory/home/mattcarp/workspace/...
in thebuild.xml
file? If you are, you need to redo yourbuild.xml
to use its current directory tree and not hard code it.