如何在Jenkins中以根用户身份运行脚本? [英] How to run a script as root in Jenkins?
本文介绍了如何在Jenkins中以根用户身份运行脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在Jenkins中以root身份而不是默认用户身份运行Shell脚本.我需要更改什么?
I need to run a shell script in Jenkins as root instead of the default user. What do I need to change?
我的sudoers文件是这样的:
My sudoers file is like this:
# User privilege specification
root ALL=(ALL) ALL
igx ALL=(ALL) ALL
%wheel ALL=(ALL) ALL
# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d
# Members of the admin group may gain root privileges
%admin ALL=(ALL) NOPASSWD:ALL
root ALL=(ALL) ALL
jenkins ALL=NOPASSWD: /var/lib/jenkins/workspace/ing00112/trunk/source/
jenkins ALL=(ALL) NOPASSWD:ALL
#Defaults:jenkins !requiretty
推荐答案
您必须使用sudo
运行脚本:
sudo /path/to/script
但是在您必须允许jenkins
在/etc/sudoers
中运行脚本之前.
But before you must allow jenkins
to run the script in /etc/sudoers
.
jenkins ALL = NOPASSWD: /path/to/script
这篇关于如何在Jenkins中以根用户身份运行脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文