如何在 Jenkins 中以 root 身份运行脚本? [英] How to run a script as root in Jenkins?

查看:52
本文介绍了如何在 Jenkins 中以 root 身份运行脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以 root 而不是默认用户身份在 Jenkins 中运行 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 运行脚本:

You must run the script using 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 中以 root 身份运行脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆