I spend several days setting up the file /etc/sudoers
to be able to give permissions to root to the user jenkins
. I have Jenkins installed on my server
This is quite possible that you are adding a wrong user to the sudoers file. This happened to me as well and the solution to add an entry in sudoers file wasn't working for me. You will need to know the actual user that your jenkins is using to execute commands. For this purpose you can add a build step (Execute shell) within your jenkins with the following command:
whoami
Then try running the jenkins job again and in the console output, you will see the user that jenkins is using to execute commands. You will then need to add this user to your sudoers file. For example if the user was 'tomcat', you will add the following line to the end of your sudoers file:
tomcat ALL=(ALL) NOPASSWD: ALL
Ref: http://techrofile.com/jenkins-sudo-no-tty-present-and-no-askpass-program-specified-with-nopasswd/