gitlab-runner配置

  CICD

变更通过rpm包安装的gitlab-runner启动参数

通过rpm包安装的runner默认会安装systemd启动脚本,所以只需要更新启动脚本即可

启动脚本位置:
/etc/systemd/system/gitlab-runner.service

编辑启动脚本:

[Unit]
Description=GitLab Runner
After=syslog.target network.target
ConditionFileIsExecutable=/usr/lib/gitlab-runner/gitlab-runner

[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/usr/lib/gitlab-runner/gitlab-runner "run" "--working-directory" "/home/gitlab-runner" "--config" "/etc/gitlab-runner/config.toml" "--service" "gitlab-runner" "--syslog" "--user" "gitlab-runner"

Restart=always
RestartSec=120

[Install]
WantedBy=multi-user.target

将ExecStart一行中’–user’后的’gitlab-runner’改为服务运行的用户,如:’www’

然后运行

systemctl daemon-reload
systemctl restart gitlab-runner

此时gitlab-runner已经通过www用户在运行了,但是因为默认的工作目录为/home/gitlab-runner,权限也是gitlab-runner用户的权限,所以需要变更权限

chown -R www.www /home/gitlab-runner

按照上面的步骤,运行用户变更完成,可以通过ps命令检查。