Furkan ozturk
Furkan ozturk

Reputation: 722

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

Upvotes: 3

Views: 10806

Answers (3)

krishan sharma
krishan sharma

Reputation: 11

I have found a solution for this and it worked

  1. Open a terminal and switch to the root user:

    sudo su

  2. Add the Jenkins user to the docker group:

    usermod -aG docker jenkins

  3. Exit the root shell:

    exit

  4. Restart the Jenkins service:

    sudo service jenkins restart

By switching to the root user in the terminal, you should have the necessary privileges to add the Jenkins user to the docker group. After completing these steps, Jenkins should have the required permissions to access the Docker daemon.

Upvotes: 1

Furkan ozturk
Furkan ozturk

Reputation: 722

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.

Upvotes: 3

towel
towel

Reputation: 2214

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.

Upvotes: 2

Related Questions