如何在Jenkins中以根用户身份运行脚本?

我需要在Jenkins中以root身份而不是默认用户身份运行Shell脚本。我需要更改什么?

我的sudoers文件是这样的:

# 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

jenkins    ALL = NOPASSWD: /path/to/script

以上是 如何在Jenkins中以根用户身份运行脚本? 的全部内容, 来源链接: utcz.com/qa/419282.html

回到顶部