Gitlab CI - gitlab-运行ner 运行 作为 root
Gitlab CI - gitlab-runner run as root
我在 iOS 上了解了持续集成,
我尝试 运行 使用 gitlab-运行ner 构建并使用 shell 作为执行者,但我遇到了 pod cannot run as root
的问题,我确定我没有使用 sudo 安装 cocoapods 并且我在 before_script
尝试 运行 whoami
是的,我的 运行ner 运行 作为 root
有人遇到同样的问题吗?如何解决?
不使用 sudo 注册 运行ner,这应该将 gitlab-runner
设置为 运行 作为您的当前用户。
所以步骤应该是:
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
记得停止你的 sudo gitlab-runner
服务,否则你可能会有多个 运行 用户在同一台机器上争夺相同的工作。
这里是 documentation 如何使用 sudo
和 gitlab-runner
用户。
我不确定,但我认为它会产生多个跑步者。
在 CentOS 8 我修改了 gitlab-runner.service
并将 --user
选项更改为 root
.
这是默认配置:
/usr/bin/gitlab-runner run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --user gitlab-runner
或
root@server# cat /etc/systemd/system/gitlab-runner.service
[Unit]
Description=GitLab Runner
After=syslog.target network.target
ConditionFileIsExecutable=/usr/bin/gitlab-runner
[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/usr/bin/gitlab-runner "run" "--working-directory" "/home/gitlab-runner" "--config" "/etc/gitlab-runner/config.toml" "--service" "gitlab-runner" "--user" "gitlab-runner"
Restart=always
RestartSec=120
[Install]
WantedBy=multi-user.target
然后我改成这样:
[Unit]
Description=GitLab Runner
After=syslog.target network.target
ConditionFileIsExecutable=/usr/bin/gitlab-runner
[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/usr/bin/gitlab-runner "run" "--working-directory" "/home/gitlab-runner" "--config" "/etc/gitlab-runner/config.toml" "--service" "gitlab-runner" "--user" "root"
User=root
Group=root
Restart=always
RestartSec=120
[Install]
WantedBy=multi-user.target
所以这部分 --user gitlab-runner
到 --user root
注意
绝对没有安全问题,只是为了测试,请确保您正在考虑安全部分。
我在 iOS 上了解了持续集成,
我尝试 运行 使用 gitlab-运行ner 构建并使用 shell 作为执行者,但我遇到了 pod cannot run as root
的问题,我确定我没有使用 sudo 安装 cocoapods 并且我在 before_script
尝试 运行 whoami
是的,我的 运行ner 运行 作为 root
有人遇到同样的问题吗?如何解决?
不使用 sudo 注册 运行ner,这应该将 gitlab-runner
设置为 运行 作为您的当前用户。
所以步骤应该是:
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
记得停止你的 sudo gitlab-runner
服务,否则你可能会有多个 运行 用户在同一台机器上争夺相同的工作。
这里是 documentation 如何使用 sudo
和 gitlab-runner
用户。
我不确定,但我认为它会产生多个跑步者。
在 CentOS 8 我修改了 gitlab-runner.service
并将 --user
选项更改为 root
.
这是默认配置:
/usr/bin/gitlab-runner run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --user gitlab-runner
或
root@server# cat /etc/systemd/system/gitlab-runner.service
[Unit]
Description=GitLab Runner
After=syslog.target network.target
ConditionFileIsExecutable=/usr/bin/gitlab-runner
[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/usr/bin/gitlab-runner "run" "--working-directory" "/home/gitlab-runner" "--config" "/etc/gitlab-runner/config.toml" "--service" "gitlab-runner" "--user" "gitlab-runner"
Restart=always
RestartSec=120
[Install]
WantedBy=multi-user.target
然后我改成这样:
[Unit]
Description=GitLab Runner
After=syslog.target network.target
ConditionFileIsExecutable=/usr/bin/gitlab-runner
[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/usr/bin/gitlab-runner "run" "--working-directory" "/home/gitlab-runner" "--config" "/etc/gitlab-runner/config.toml" "--service" "gitlab-runner" "--user" "root"
User=root
Group=root
Restart=always
RestartSec=120
[Install]
WantedBy=multi-user.target
所以这部分 --user gitlab-runner
到 --user root
注意
绝对没有安全问题,只是为了测试,请确保您正在考虑安全部分。