我在遠程Ubuntu服務器上有一個腳本。我想詹金斯打造的是成功後執行腳本,但錯誤說是這樣的:通過Jenkins運行命令?
sudo: no tty present and no askpass program specified
的配置如下,
誰能幫助我? 謝謝。
我在遠程Ubuntu服務器上有一個腳本。我想詹金斯打造的是成功後執行腳本,但錯誤說是這樣的:通過Jenkins運行命令?
sudo: no tty present and no askpass program specified
的配置如下,
誰能幫助我? 謝謝。
問題是您的腳本在某個時候使用了sudo
。通常的解決方法是添加腳本,要求您使用sudo
到sudoers。
示例:在您的腳本中使用sudo service apache2 reload
,現在創建一個包含該行的bash腳本並將該腳本添加到sudoers文件中。
新腳本名稱:/home/quaser/restart-apache.sh
用途:visudo
添加到文件底部:現在
jenkins ALL=(ALL) NOPASSWD: /home/quaser/restart-apache.sh
,在您的腳本變化:sudo service apache restart
到sudo /home/quaser/restart-apache.sh
你不應該問爲密碼。
謝謝@uncletall,明白了。 –
我有同樣的問題,我解決了通過/etc/sudoers
cat /etc/sudoers| grep tty
#Defaults requiretty
評論Defaults requiretty
從手冊頁:
man sudoers | grep requiretty -A 5
requiretty If set, sudo will only run when the user is logged in
to a real tty. When this flag is set, sudo can only be
run from a login session and not via other means such
as cron(8) or cgi-bin scripts. This flag is off by
default.
見http://stackoverflow.com/questions/21659637/sudo -no-tty-present-and-no-askpass-program-specified-netbeans – uncletall