Jenkins? Tomcat? Running Code w/ Permissions?
This script will probably help you! If you need to run some "SUDO" commands from Jenkins, you will probably need to first:
1) Add jenkins user to SUDO, and
2) Avoid passwords.
The following code will do it like a miracle:
echo 'jenkins ALL= NOPASSWD: ALL' >> /etc/sudoers echo 'Defaults:jenkins !requiretty' >> /etc/sudoers
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)






Comments
Adam Evans replied on Sat, 2013/02/09 - 5:24pm
Depending who has access to configure your Jenkins jobs this is a bad idea as essentially you are granting anyone root access who can configure a job using the ALL option.
I like to manually specify in the sudoers which commands can be run by jenkins using the NOPASSWD as you did. It's a little more inconvenient but gives extra piece of mind. Sometimes I'll also wrap a group of commands up in a shell script and add that to the sudoers.
Moshe Kaplan replied on Sat, 2013/02/09 - 6:35pm
in response to:
Adam Evans
Thanks Adam for the good advice.
Usually Jenkins is considered to be a trusted environment, but keeping it a little bit more secure will not hurt anybody,
Keep Performing,
Moshe Kaplan