Jenkins系统中添加执行脚本的时候,有一些命令是需要sudo权限和来执行的,可以在root权限下添加一下Jenkins账号的权限
1、添加不需要密码可sudo执行指定命令的权限
cd /etc
chmod u+w /etc/sudoers
vi /etc/sudoers
##########################################
jenkins ALL=NOPASSWD: /usr/bin/qemu-nbd,/usr/bin/mount,/usr/bin/umount
//即允许jenkins用户使用sudo执行qemu-nbd、mount、umount的命令,且执行时不需要输入密码
2、解决:sudo: no tty present and no askpass program specified(sudo版本较低的可以先升级一下sudo)
vi /etc/sudoers
##########################################
#
#Defaults requiretty
Defaults:jenkins !requiretty
#
# Refuse to run if unable to disable echo on the tty. This setting should also be
# changed in order to be able to use sudo without a tty. See requiretty above.
#
Defaults visiblepw