Run sudo in Jenkins

Some script need to run with sudo command, if we get error that permission deny, we need to run with sudo.

To enable sudo in jenkins, need to add bellow line to /etc/sudoers

jenkins ALL=NOPASSWD: /pathOfMyScript

But if you don't use root user to make such change, you will get error: 

sudo: /etc/sudoers is owned by uid xxx, should be 0

Bcoz we normally won't use root for dev. First need to enable root user:

Setting>user>Login Options>Network account server>Join buton>Open Directory Utility

In "Edit" menu, enable root user and set password, then logout and user root acc.

runn bellow command:

$cd etc
$chgrp wheel sudoers
$chown root /etc/sudoers

* User root to enhance sudoers will better.

猜你喜欢

转载自shappy1978.iteye.com/blog/2341600
run