在 linux 中更改 jenkins 的工作区

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9461161/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:51:15  来源:igfitidea点击:

changing workspace of jenkins in linux

linuxjenkinsworkspace

提问by vinod

I've installed Jenkins on Linux, and I'm new to both. I configured a job with a custom workspace /root/xxxx (directory structure already in place). It gives me the following error:

我已经在 Linux 上安装了 Jenkins,而且我对两者都是新手。我使用自定义工作区 /root/xxxx(目录结构已经就位)配置了一个作业。它给了我以下错误:

Building in workspace /root/bhanu
java.io.IOException: Failed to mkdirs: /root/bhanu
at hudson.FilePath.mkdirs(FilePath.java:847)

Another question: when executing copycommand in Execute Shellbuild step it gives me 'permission denied' error. From the console output the copy command works fine. Here is the error:

另一个问题:在Execute Shell构建步骤中执行复制命令时,它给了我“权限被拒绝”错误。从控制台输出复制命令工作正常。这是错误:

+ cp /home/user1/victor.war /root/apache-tomcat-6.0.29/webapps/
cp: accessing '/root/apache-tomcat-6.0.29/webapps/': Permission denied

When I try to set permissions in shell script in Jenkins it gives me 'permission denied' error:

当我尝试在 Jenkins 的 shell 脚本中设置权限时,它给了我“权限被拒绝”错误:

+ chmod a+rwx /root/apache-tomcat-6.0.29/webapps/
chmod: cannot access '/root/apache-tomcat-6.0.29/webapps/': Permission denied

采纳答案by Martijn Rutten

Try

尝试

ps aux |grep jenkins

to see what user the process has. On Linux, jenkins uses the JENKINS_USERvariable to define what user it should run as. For a standard Ubuntu package install, the config file in /etc/default/jenkinsspecifies the user in the JENKINS_USERvariable.

查看进程有哪些用户。在 Linux 上,jenkins 使用JENKINS_USER变量来定义它应该以什么用户身份运行。对于标准的 Ubuntu 软件包安装,配置文件在变量中/etc/default/jenkins指定用户JENKINS_USER

In the same config file, you can also specify the default workspace location using JENKINS_HOME. Make sure that is owned by the user you specified in JENKINS_USERto have Jenkins access files.

在同一个配置文件中,您还可以使用JENKINS_HOME. 确保它归您指定的用户所有,JENKINS_USER以便 Jenkins 访问文件。

For slave nodes, specify the default workspace on the slave machine in the slave configuration under Manage Jenkins > Manage Nodes > > Configure > Remote FS root. Again, this should have read/write/execute permissions for the JENKINS_USERuser.

对于从节点,在管理 Jenkins > 管理节点 > > 配置 > 远程 FS 根下的从配置中指定从机器上的默认工作区。同样,这应该对JENKINS_USER用户具有读/写/执行权限。