Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins fails: a terminal is required to read the password; either use the -S option to read from standard input

While Jenkins building, it gives an error on console output like:

sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper

How can i fix this situation?


There is this command in Execute Shell in configure:

sudo pnpm run build
sudo kill -9 $(sudo lsof -t -i:3000)

Output:

16:42:03  > git config core.sparsecheckout # timeout=10
16:42:03  > git checkout -f 9998780d6a154bab01b4c010616f25a6f018d80c # timeout=10
16:42:03 Commit message: "fix swr"
16:42:03  > git rev-list --no-walk 9998780d6a154bab01b4c010616f25a6f018d80c # timeout=10
16:42:04 [ProjectReact] $ /bin/sh -xe /tmp/jenkins14253074063433648143.sh
16:42:04 + sudo pnpm run build
16:42:04 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
16:42:04 Build step 'Execute shell' marked build as failure
16:42:04 Finished: FAILURE

If i dont use "sudo" command at beginning of the pnpm command but i needed to use it for kill port and start again

like image 817
Furkan ozturk Avatar asked Jan 30 '26 00:01

Furkan ozturk


2 Answers

I found a solution for the usage of sudo command in jenkins execute shell.

sudo su    
nano /etc/sudoers

add following line under the comment #User privilege specification.

jenkins ALL= NOPASSWD: ALL

After this, I could use "sudo" command in jenkins.

like image 191
Furkan ozturk Avatar answered Feb 02 '26 07:02

Furkan ozturk


Remove sudo from your script and let pnpm run without it -- it doesn't require root permissions anyway.

sudo is meant to be used in the terminal by a human user, and by default it requires the user's password to run commands with elevated privileges.

When running jobs on Jenkins you shouldn't be using sudo.

like image 41
towel Avatar answered Feb 02 '26 07:02

towel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!