Search code examples
gitlabgitlab-cigitlab-ci-runner

'gitlab-runner' unexpectedly runs as root


I'm new to continous integration on iOS, I try to run build with gitlab-runner and use shell as executor but I got issue that pod cannot run as root I am sure that I am not installing cocoapods with sudo and I try run whoami at before_script and that's right my runner run as root enter image description here

How can I make gitlab-runner not run as root?


Solution

  • Register the runner without sudo, and that should set the gitlab-runner to run as your current user.

    So steps should be:

    sudo curl --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64
    
    sudo chmod +x /usr/local/bin/gitlab-runner
    
    gitlab-runner register ...
    
    gitlab-runner install
    

    Remember to stop your sudo gitlab-runner service otherwise you could have multiple runners on the same machine fighting for the same jobs.