3

I get the following error when i try to run the pipeline

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

Has this got something to do with gitlab-runner permissions? I have tried giving it full access, but still it fails. Can someone help me out?

I am following the guide mentioned on gitlab at https://docs.gitlab.com/runner/install/linux-manually.html

Gitlab Runner Version: 13.4.1 Git revision: e95f89a0 Git branch: 13-4-stable GO version: go1.13.8 Built: 2020-09-25T20:03:43+0000 OS/Arch: linux/amd64

Ubuntu Distributor ID: Ubuntu Description: Ubuntu 20.04.1 LTS Release: 20.04 Codename: focal

  • It's good to share what's happening in the pipeline. From the question it's not clear what commands are executed, so it's hard to help. – Ilia Kondrashov Oct 10 '20 at 14:08

3 Answers3

5

I seemed to have found a workaround.

as answered by @maksim.danilin on https://gitlab.com/gitlab-org/gitlab-runner/-/issues/2126

  • Remove all files from .* files from /home/gitlab-runner
  • rm * should do the trick if you are inside gitlab-runner folder

Futhermore follow the solution by @Reactgular (How to use sudo in build script for gitlab ci?)

  • Grant sudo permissions to the gitlab-runner user
    • $ sudo usermod -a -G sudo gitlab-runner
  • Remove the password restriction for sudo for the gitlab-runner user
    • $ sudo visudo
  • Add the following to the bottom of the file
    • gitlab-runner ALL=(ALL) NOPASSWD: ALL
1

Just an additional information if the error is showing as "command not found " . Ensure you have /usr/local/bin/ in $PATH for root or you might get a command not found error. Alternately, you can install gitlab-runner in a different location, like /usr/bin/.

just check

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

I have documented gitlab runner setup. Feel free to refer! https://github.com/edureka2021/gitlab.git

0

I ran into this same error recently setting up a gitlab CI runner. In my case the sudo error was masking a different error: the command was not found. Just as a sanity-check make sure you can run the command from a shell as the CI user to ensure you're not seeing a false positive from sudo.

James Moore
  • 389
  • 2
  • 7