更改 Gitlab CI Runner 用户 [英] Change Gitlab CI Runner user
问题描述
目前,当我在 GitlabCI 中开始构建时,它在 gitlab-runner 用户下运行.我想把它改成公司的内部用户.我没有找到/etc/gitlab-runner/config.toml 的任何参数来解决这个问题.
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.
我目前的配置:
concurrent = 1
[[runners]]
name = "deploy"
url = ""
token = ""
executor = "shell"
推荐答案
运行ps aux
可以看到:
/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
服务正在使用选项 --user
运行.
Service is running with option --user
.
所以让我们改变它,这取决于发行版.你正在运行它.如果是systemd,有一个文件:
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:
/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,让我们现在更改此文件:
Bingo, let's change this file now:
gitlab-runner uninstall
gitlab-runner install --working-directory /home/ubuntu --user ubuntu
重启机器或重新加载服务(即systemctl daemon-reload
),等等!
reboot the machine or reload the service (i.e. systemctl daemon-reload
), et voilà!
这篇关于更改 Gitlab CI Runner 用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!