Gitlab Runner在单独的服务器上

时间:2017-06-02 13:15:05

标签: gitlab gitlab-ci gitlab-ci-runner gitlab-omnibus gitlab-ce

我想在单独的服务器上安装GitLab Runner,但是当我尝试连接到GitLab时,我收到了:

Running in system-mode.                            

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
<URL>
Please enter the gitlab-ci token for this runner:
<TOKEN>       
Please enter the gitlab-ci description for this runner:
[<url>]: <description>
Please enter the gitlab-ci tags for this runner (comma separated):

Whether to lock Runner to current project [true/false]:
[false]: 
ERROR: Registering runner... failed                 runner=<runner-token> status=couldn't execute POST against <url>/api/v4/runners: Post <url>/api/v4/runners: dial tcp 172.17.0.2:80: getsockopt: connection refused
ERROR: Checking GitLab compatibility... not-compatible  reason=GitLab Runner >= 9.0 can be used ONLY with GitLab CE/EE >= 9.0 result=-1 runner=<runner-token> statusText=couldn't execute POST against <url>/api/v4/runners/verify: Post <url>/api/v4/runners/verify: dial tcp 172.17.0.2:80: getsockopt: connection refused
PANIC: Failed to register this runner. Perhaps you are having network problems 

如果我从POSTMAN创建POST请求我可以创建跑步者,但是当我从gitlab-ci尝试时我不能。你知道什么是错的吗?我们的Gitlab在另一台服务器上,我想分离Gitlab和Gitlab-ci。我希望Gitlab-CI位于一个单独的服务器上,而不是Gitlab所在的同一服务器上。怎么做,你知道吗?

2 个答案:

答案 0 :(得分:0)

您的问题有两种可能的原因:

  1. 版本不匹配:可能您的跑步者与您的GitLab版本不兼容,如消息中所述:ERROR: Checking GitLab compatibility... not-compatible reason=GitLab Runner >= 9.0 can be used ONLY with GitLab CE/EE >= 9.0 result=-1。检查您的GitLab实例版本,并确保您的跑步者版本与之兼容。

      

    Runners 9.0及更高版本使用新的v4 API,需要最少的GitLab 9.0。

  2. 网络问题:由于某些网络限制或某些阻止,您的Gitlab Runner无法访问GitLab服务器。发生这种情况时,会显示与上面相同的错误消息。尝试从GitLab Runner服务器卷曲 <url>/api/v4/runners/verify 以了解这是否是问题。

答案 1 :(得分:0)

是的,我解决了我的问题。问题是什么:我创建了docker-compose.yml文件,它看起来像这样:

web:
  image: 'gitlab/gitlab-runner:latest'
  restart: always
  hostname: domain
  container_name: gitlab-runner
  volumes:
    - '/storage/gitlab-runner/gitlab-runner/config:/etc/gitlab-runner'
    - '/var/run/docker.sock:/var/run/docker.sock

但是,当我尝试连接gitlab和gitlab ci时,我看到了这一行: Please enter the gitlab-ci description for this runner: [<url>]: <description> 我收到了[<url>],但我必须收到随机令牌和网址。然后我决定删除hostname: domain并再次启动该过程。一切顺利。所以我的新docker-compose.yml文件看起来像:

web:
  image: 'gitlab/gitlab-runner:latest'
  restart: always
  container_name: gitlab-runner
  volumes:
    - '/storage/gitlab-runner/gitlab-runner/config:/etc/gitlab-runner'
    - '/var/run/docker.sock:/var/run/docker.sock

现在一切正常。