
[英]Jenkins running tomcat8 sudo: no tty present and no askpass program specified with NOPASSWD
[英]Jenkins sudo: no tty present and no askpass program specified with NOPASSWD [duplicate]
我花了几天时间设置文件/etc/sudoers
以便能够向用户jenkins
授予 root 权限。 我在我的服务器上安装了 Jenkins,因为我用 symfony、ionic、neo4j 等托管了几个项目......问题是我不能用 ionic 在项目中构建,我收到这个错误: sudo: no tty present and no askpass program specified.
这是我的 /etc/sudoers 文件的内容:
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
jenkins ALL=(ALL) NOPASSWD: ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
我已经在问题的评论中测试了@Jayan 描述的解决方案。 您必须在文件末尾包含新行:
解决方案: https : //stackoverflow.com/a/24648413/54506
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
jenkins ALL=(ALL) NOPASSWD: ALL
这很可能是您在 sudoers 文件中添加了错误的用户。 这也发生在我身上,在 sudoers 文件中添加条目的解决方案对我不起作用。 您需要知道 jenkins 用来执行命令的实际用户。 为此,您可以使用以下命令在 jenkins 中添加构建步骤(执行 shell):
whoami
然后再次尝试运行 jenkins 作业,在控制台输出中,您将看到 jenkins 用于执行命令的用户。 然后,您需要将此用户添加到您的 sudoers 文件中。 例如,如果用户是 'tomcat',您将以下行添加到 sudoers 文件的末尾:
tomcat ALL=(ALL) NOPASSWD: ALL
参考: http : //techrofile.com/jenkins-sudo-no-tty-present-and-no-askpass-program-specified-with-nopasswd/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.