Go Back

Using Sudo In Jenkins Shell

Updated on 04 September, 2019

Learning

To run shell commands on Jenkins with sudo previleges we have to edit the /etc/sudoers file.
It is not a good practice to modify it directly like for eg

sudo vim /etc/sudoers

Don't do this. If there are any syntax errors in the edit it may cause problems. The best way to edit /etc/sudoers file is by using visudo

sudo visudo

This will open the sudoers file. We have to add the following line to the file.

jenkins ALL=(ALL) NOPASSWD: ALL

Now exit the editor by pressing ESC and :wq and hitting Enter.

Now you are ready to use sudo in your Jenkins shell.

Go Back