Jenkins running tomcat8 sudo: no tty present and no askpass program specified with NOPASSWD Jenkins running tomcat8 sudo: no tty present and no askpass program specified with NOPASSWD jenkins jenkins

Jenkins running tomcat8 sudo: no tty present and no askpass program specified with NOPASSWD


There might be a workaround: As Barmar pointed out in a comment to the post "Use sudo without password INSIDE a script", it is possible to allow a dedicated script be executed by a sudoer. Assume you have a line

 jenkins ALL=(ALL) NOPASSWD:/path/to/restart.sh

this means that Jenkins can do sudo /path/to/restart.sh without a password.

If you now put your command service tomcat8 restart in restart.sh, a sudo /path/to/restart.sh should do the job.


Try turning off requiretty for the jenkins user. I would recommend using command aliases in your sudoers file as well.

Cmnd_Alias RESTART_TOMCAT = /sbin/service tomcat8 *, /etc/init.d/tomcat8 *Defaults:jenkins !requirettyjenkins  ALL=(root) NOPASSWD: RESTART_TOMCAT