Jenkins sudo: there is no tty present and do not skip the program specified in NOPASSWD

I spend several days creating archvio /etc/sudoers to be able to allow root jenkins user. I have Jenkins installed on my server because I have several projects with symfony, ionic, neo4j, etc. The problem is that I cannot build projects with ionic, I get this error: sudo: no tty present and no askpass program specified. This is the content of the / etc / sudoers file:

 # # 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 
+7
debian tty jenkins sudo sudoers
source share
2 answers

I tested the solution described by @Jayan in the comments on the question. You should include a new line at the end of the file:

Solution: fooobar.com/questions/30580 / ...

 # # 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 
+13
source share

It is possible that you are adding the wrong user to the sudoers file. This happened to me, and the decision to add an entry to the sudoers file did not work for me. You will need to know the actual user that your jenkins use to execute commands. To do this, you can add the Execute shell build step to your jenkins with the following command:

 whoami 

Then try to run the jenkins task again and on the console output, you will see a user who uses jenkins to execute commands. Then you will need to add this user to the sudoers file. For example, if the user was "tomcat", you add the following line to the end of the sudoers file:

 tomcat ALL=(ALL) NOPASSWD: ALL 

Link: http://techrofile.com/jenkins-sudo-no-tty-present-and-no-askpass-program-specified-with-nopasswd/

0
source share

All Articles