I run a shell script (Centos 6.7) from jenkins containing this command, in order import root environment:
env -i `cat /home/admin/root_environment.sh` /home/admin/create_user.sh
The root_environment was generated with
env > root_environment.sh
the script create_user.sh contains
/usr/sbin/useradd -p "pass" "username"
Jenkins is running with its own jenkins user. The script create_user.sh is working correctly if I run it as root, however, running from jenkins I get:
useradd: cannot lock /etc/passwd; try again later