When I'm executing a unix command in jenkins job (through execute shell) with sudo, it throws error like this:
..../bin/sh -xe /tmp/hudson7505852448142784880.sh
+ sudo whoami
/tmp/hudson7505852448142784880.sh: line 2: sudo: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Jenkins runs with 'jenkins` user. Just cause it works in terminal with your logged in user, doesn't mean that it's configured to work with 'jenkins' user.
From your terminal, do:
sudo su jenkins
and then try running sudo
from jenkins's user
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.