首页 > 解决方案 > 在 CentOS 上启动 gitlab-runner 注册失败

问题描述

我已经在 CentOS 机器上安装了 gitlab-runner,但是在注册步骤它失败并显示“连接被拒绝”:

sudo /usr/local/bin/gitlab-runner register --non-interactive --url "https://%myGitlab%/" --registration-token "%myToken%" --executor "shell" --description "TestServerRunner" --tag-list "TestRunner, CIOnTest"
Runtime platform                                    arch=amd64 os=linux pid=3149 revision=4b9e985a version=14.4.0
Running in system-mode.

ERROR: Registering runner... failed                 runner=yoqL_Qsh status=couldn't execute POST against https://%myGitlab%/api/v4/runners: Post https://%myGitlab%/api/v4/runners: dial tcp %myGitlabIp%:443: connect: **connection refused**
PANIC: Failed to register the runner. You may be having network problems.

但是,如果我尝试连接到 gitlab.com,它会打印出正常的“错误”——错误的令牌:

sudo /usr/local/bin/gitlab-runner register --non-interactive --url "https://gitlab.com/" --registration-token "%myToken%" --executor "shell" --description "TestServerRunner" --tag-list "TestRunner, CIOnTest"
Runtime platform                                    arch=amd64 os=linux pid=8259 revision=4b9e985a version=14.4.0
Running in system-mode.

ERROR: Registering runner... forbidden (check registration token)  runner=yoqL_Qsh
PANIC: Failed to register the runner. You may be having network problems.

可能有什么问题?Ping 到 %MyGitlabIp% 存在。

标签: gitlabgitlab-ci-runner

解决方案


这将是您的运行器机器和您的 gitlab 实例之间的连接与网络相关的错误。虽然 ping 实例可能正常工作,但 ICMP (ping) 流量使用与 HTTPS 流量不同的端口和协议。如果你试图curl https://<my instance domain>从你的盒子里跑出来,你可能会得到一个错误。您应该检查自托管 gitlab 实例上的防火墙规则。

听起来这是通过在运行自托管 gitlab 实例的机器上打开防火墙规则来解决的。


推荐阅读