为什么gitlab-runner无法克隆我的项目?(主机名不正确,连接失败)

Joe*_*Joe 7 git gitlab gitlab-ci gitlab-ci-runner

我设置了一个Gitlab服务器,需要使用gitlab-runner.exe运行Windows测试.

gitlab-runner的执行器设置为shell,config.toml看起来像

concurrent = 1
check_interval = 0

[[runners]]
  name = "PC123"
  url = "http://1.2.3.4/ci"
  token = "cd2b093adc5ca09ea41ee4eadb0752"
  executor = "shell"
  [runners.cache]
Run Code Online (Sandbox Code Playgroud)

当测试在提交时生成时,它将失败

Cloning into 'C:/git/builds/ac70aeb9/0/test/myproject'...
fatal: unable to access 'http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@localhost/test/boundaries.git/': Failed to connect to localhost port 80: Connection refused
Run Code Online (Sandbox Code Playgroud)

我想问题是URL中的主机名"localhost",它指的是gitlab-runner所在的机器.当我在开始时设置服务器时,我使用'localhost'作为服务器主机名.这可能不是最好的主意.:)

在此期间我改变了这个"localgit",但URL没有调整,它仍然显示"localhost".(服务器重启,gitlab-runner servive重启).

可能是服务器的主机名存储在主机名仍然是我克隆的原始仓库中的某个位置localhost.git/config显示正确的IP:

[remote "origin"]
    url = http://1.2.3.4/test/myproject.git
Run Code Online (Sandbox Code Playgroud)

我发现了另一个问题(GitLab运行器无法通过http克隆存储库)提到了一种将其他主机添加到gitlab-runner的方法config.toml,比如

[runners.docker]
    extra_hosts = ["ci.mygitlab:127.0.0.1"]
Run Code Online (Sandbox Code Playgroud)

但我必须使用shell执行者,而不是docker.

Joe*_*Joe 3

如此处所述,解决方案是替换host: localhostGitlab 配置文件中的条目/home/git/gitlab/config/gitlab.yml为主机的 IP 地址。

更换前:

  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: localhost
Run Code Online (Sandbox Code Playgroud)

更换后:

  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: 10.0.1.2
Run Code Online (Sandbox Code Playgroud)