shell - 如何在 Jenkins 中以 root 身份运行脚本?

标签 shell hudson jenkins root

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

关于shell - 如何在 Jenkins 中以 root 身份运行脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11880070/

相关文章:

linux - Tmux .tmux.conf 无法正确加载

shell - zsh zle 移位选择

database - 触发 Jenkins 基于数据库更改构建

maven-2 - Hudson 和 Maven 测试运行两次

iphone - 在Mac+Tomcat上设置Hudson的进程用户

docker - 如何在 Jenkins 作业中从容器内的脚本运行 repo

linux - 无法在 shell 脚本中运行 if 条件

c - 在 C 中编写一个 shell 我的程序无法退出()

node.js - 如何通过 Jenkins 运行 npm start 来启动应用程序

maven - 如何创建 pom.xml 来编译我的 Jenkins Pipeline 共享库?