Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Gitlab CI Runner user

Currently when I start a build in GitlabCI it is running under gitlab-runner user. I want to change it the company's internal user. I didn't find any parameter to the /etc/gitlab-runner/config.toml which is solve that.

My current configuration:

concurrent = 1 [[runners]]   name = "deploy"   url = ""   token = ""   executor = "shell" 
like image 402
PumpkinSeed Avatar asked May 12 '16 13:05

PumpkinSeed


People also ask

Which user does Gitlab runner run as?

gitlab-ci. yml scripts are running as user gitlab-www now. If this one has same uid as host mounts, you are also able to deploy directly to host folders.

How do I change my Gitlab runner?

For a shared runner, have an administrator go to the GitLab Admin Area and click Overview > Runners. For a group runner, go to Settings > CI/CD and expand the Runners section. For a project-specific runner, go to Settings > CI/CD and expand the Runners section.

Where is Gitlab runner configuration?

You can find the config. toml file in: /etc/gitlab-runner/ on *nix systems when GitLab Runner is executed as root (this is also the path for service configuration)


1 Answers

Running ps aux you can see:

/usr/bin/gitlab-ci-multi-runner run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user gitlab-runner 

Service is running with option --user.

So let's change this, it depends on what distro. you are running it. If systemd, there is a file:

/etc/systemd/system/gitlab-runner.service:

[Service] StartLimitInterval=5 StartLimitBurst=10 ExecStart=/usr/bin/gitlab-ci-multi-runner "run" "--working-directory" "/home/gitlab-runner" "--config" "/etc/gitlab-runner/config.toml" "--se 

Bingo, let's change this file now:

gitlab-runner uninstall  gitlab-runner install --working-directory /home/ubuntu --user ubuntu 

reboot the machine or reload the service (i.e. systemctl daemon-reload), et voilà!

like image 149
Thomas Decaux Avatar answered Nov 09 '22 03:11

Thomas Decaux