web-dev-qa-db-ja.com

Jenkins Sudo:ttyが存在せず、NOPASSWDで指定されたaskpassプログラムがありません

ファイル/etc/sudoersのセットアップに数日を費やして、ユーザーjenkinsにrootの許可を与えることができます。 symfony、ionic、neo4jなどで複数のプロジェクトをホストしているため、サーバーにJenkinsをインストールしています。問題は、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
17
Ander Acosta

質問のコメントで@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
29
Ander Acosta

これは、sudoersファイルに間違ったユーザーを追加している可能性があります。これは私にも起こり、sudoersファイルにエントリを追加する解決策はうまくいきませんでした。 jenkinsがコマンドを実行するために使用している実際のユーザーを知る必要があります。このために、次のコマンドを使用してジェンキン内にビルドステップ(シェルの実行)を追加できます。

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/

3
yasirfarooqui

これは、問題を解決するために実行する手順を詳しく説明するための単なる応答です。

まず、Jenkins GUIがbashシェルスクリプトの実行に使用しているユーザーを特定します。

プロジェクトを選択>構成>実行可能シェルにwhoamiを入力>保存して今すぐビルド enter image description here ビルド履歴で結果を表示>コンソール出力をクリック

ユーザーは、Tomcatまたはjenkinsなどです。

JenkinsサーバーへのSSH

  1. _Sudo su_
  2. visudo
  3. Tomcat ALL=(ALL) NOPASSWD: ALL#表示されるユーザーがTomcatの場合 enter image description here
0
wale