How to make permanent changes to /etc/sudoers

I’m trying to setup a Jenkins job that need to run an executable file under sudo

I do

  • sudo nano /etc/sudoers
  • add jenkins ALL=(ALL) NOPASSWD:ALL at the end of file
  • CTRL + X and confirm file save prompt

After that when I run the build that works fine but on the next run it fails and when I check /etc/sudoers I see that my change dropped…

What can be the reason and how to make the change work constantly?

Asked By: JaSON

||

So to allow Jenkins to execute script under sudo without password prompt I created /etc/sudoers.d/jenkins and add this line

jenkins ALL=NOPASSWD:/path/to/script.sh
Answered By: JaSON
Categories: Answers Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.