skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    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.


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search