1

For some reason jenkins cannot execute sudo related command when the build is invoked from the "Build now" button on the browser or when triggered by a git push. I get errors like

"jenkins is not in the sudoers file. This incident will be reported."

However I ssh into the instance and do

sudo usermod -a -G sudo jenkins

I verified it by

groups jenkins

where the output is

jenkins : jenkins sudo

I also attempted to execute the command myself in the console and it works without a problem

su jenkins
cd /var/lib/jenkins/workspace/myrepo/build/
sudo make install

I also doubled checked

sudo visudo

and there is

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

What am I doing wrong?

user3667089
  • 2,996
  • 5
  • 30
  • 56
  • 1
    Why on earth do you want to run jenkins as sudo? – Cyclonecode Aug 24 '16 at 19:18
  • @Cyclone one repo depends on the library from another repo, if will be nice if the libraries will be updated instantly on the git push. I could do a cronjob that does a daily pull and sudo make install but the update won't be instant – user3667089 Aug 24 '16 at 19:22
  • Well, in that case there should be not reason to run jenkins as root, you just need to give the desired access to git to jenkins? – Cyclonecode Aug 24 '16 at 19:24
  • This might point you in the right direction: http://stackoverflow.com/questions/8639501/jenkins-could-not-run-git – Cyclonecode Aug 24 '16 at 19:28
  • @Cyclone the libraries need to be installed to /usr/local/lib and the headers to /usr/local/include in order to successfully link it for the other repo. Just like how open source code like OpenCV and PCL install their library to the system – user3667089 Aug 24 '16 at 19:32

0 Answers0