title: Best practices to avoid Jenkins error: sudo: no tty present and no askpass program specified
body: <p>When running any sudo command from Jenkins I get the following error: <code>sudo: no tty present and no askpass program specified</code>.</p>
  
  <p>I understand that I can solve this by adding a <strong>NOPASSWD</strong> entry to my <code>/etc/sudoers</code> file which will allow user <strong>jenkins</strong> to run commands without needing a password. I can add an entry like this:</p>
  
  <pre><code>%jenkins ALL=(ALL)NOPASSWD:/home/me/dir/script.sh
  </code></pre>
  
  <p>...but this leads to the following issue: <a href="https://stackoverflow.com/questions/17414330/how-to-avoid-specifying-full-path-in-sudoers-file">https://stackoverflow.com/questions/17414330/how-to-avoid-specifying-full-path-in-sudoers-file</a> </p>
  
  <p>I can add an entry like this: </p>
  
  <pre><code>%jenkins ALL=NOPASSWD: ALL
  </code></pre>
  
  <p>...but this allows user jenkins to avoid the password prompt for <strong>ALL</strong> commands, which seems a bit unsafe. I'm just curious what my options are here, and if there are any best practices I should consider.</p>