无法为shell脚本允许对jenkins进行sudo访问

时间:2016-07-22 11:22:58

标签: linux jenkins ssh centos

我正在努力让jenkins找到一份运行此命令的工作:

sudo -n sh /opt/sonar/bin/linux-x86-64/sonar.sh start

我使用visudo进行编辑,以便在CentOS机器上添加以下行:

jenkins ALL=(ALL)       NOPASSWD: /opt/sonar/bin/linux-x86-64/sonar.sh

然而,当我跑完他的工作时,我仍然得到:

Building on master in workspace /data/jenkins/Start_Sonar_Job/workspace
[workspace] $ /bin/sh -xe /tmp/hudson8942100529506642093.sh
+ sudo -n sh /opt/sonar/bin/linux-x86-64/sonar.sh start
sudo: a password is required
Build step 'Execute shell' marked build as failure
Finished: FAILURE

我缺少什么配置?

1 个答案:

答案 0 :(得分:0)

试试这个;

Cmnd_Alias      CUSTOM_CMD=/opt/sonar/bin/linux-x86-64/sonar.sh
jenkins        ALL = (root) NOPASSWD:CUSTOM_CMD