Running shell commands which have sudo
might not worked as expected as jenkins doesn’t have access to read passwords from your linux box.
Are you familiar with below error?
sudo: no tty present and no askpass program specified
Jenkins use your linux box with user called “jenkins”. We might want to tell the OS not to ask password while executing commands.
Below are the steps to achieve this.
#1 open /etc/sudoers
type sudo vi /etc/sudoers
. This will open your file in edit mode.
#2 Add/Modify jenkins user
Look for the entry for jenkins user. Modify as below if found or add a new line.
jenkins ALL=(ALL) NOPASSWD: ALL
#3 Save and Exit from edit mode
Press ESC
and type :wq
and hit Enter
. You should be out of the edit mode.
Please try to re-run you Jenkins job. You should not see the above mentioned error and sudo
commands will run without any problem.
Thanks.
S with ♥
It is bad to edit directly the sudoers file with vi, because, if you do an error, you lost all super permission. The better way is to use visudo which generate a tmp file and validate the sudoerfile before saving
Thanks!!!
Thank You Shubham its really helpful for me. Keep Going