问题描述
我最近开始使用Jenkins进行集成.一切都很好,直到我在没有shell命令的情况下在主节点上运行作业,但我必须在包含shell命令的主节点和从属节点上运行作业.我无法以root用户身份运行这些Shell命令.我尝试过
I have recently started using Jenkins for integration. All was well until I was running jobs on master node without shell command but I have to run jobs on master as well as slave node which contains shell commands to. I am not able to run those shell commands as root user. I have tried
- 使用
SSH Keys
. - 在shell命令中设置用户名.
- 使用
sudo
.
- Using
SSH Keys
. - Setting user name in shell commands.
- Using
sudo
.
每次使用上述任何一种方法时,都会出现permission denied
错误.
I am getting permission denied
error every time I use any of the above methods.
推荐答案
您需要修改jenkins
用户的权限,以便您可以运行shell命令.您可以将jenkins作为服务安装(下载rpm软件包).您可能需要更改端口,因为默认情况下,它在8080端口上运行http,而在8009端口上运行AJP.
You need to modify the permission for jenkins
user so that you can run the shell commands.You can install the jenkins as as service (download the rpm package), You might need to change the ports because by default it runs http on 8080 and AJP on 8009 port.
以下过程适用于CentOS
1.打开此脚本(使用VIM或其他编辑器):
Following process is for CentOS
1. Open up the this script (using VIM or other editor):
vim /etc/sysconfig/jenkins
2.找到此$JENKINS_USER
并更改为"root":
2. Find this $JENKINS_USER
and change to "root":
$JENKINS_USER="root"
3.然后更改Jenkins主页,webroot和日志的所有权:
3. 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
4)重新启动Jenkins并检查用户是否已更改:
4) Restart Jenkins and check the user has been changed:
service jenkins restart
ps -ef | grep jenkins
这篇关于以root用户身份在jenkins中运行shell命令吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!