Search code examples
jenkinssshsudo

How to enable sudo from Jenkins SSH plugin?


I tried running a sudo command from the Jenkins SSH plugin but got the following error:

sudo: sorry, you must have a tty to run sudo

My Jenkins job needs to be able to stop and start a service and I was unable to enable the remote user to do it without sudo.

Is there any way to enable sudo-ing from Jenkins?


Solution

  • I managed to enable sudo from Jenkins by changing sudoers on the remote host (SSH target) to not require tty:

    #Defaults    requiretty