为什么gitlab-runner无法克隆我的项目? (不正确的主机名,无法连接) [英] Why can't gitlab-runner clone my project? (Incorrect hostname, failed to connect)
问题描述
我设置了一个Gitlab服务器,需要使用gitlab-runner.exe运行Windows测试.
I set-up a Gitlab server and need to run tests Windows using gitlab-runner.exe.
gitlab-runner的执行程序设置为shell
,config.toml
看起来像
The gitlab-runner's executor is set to shell
, the config.toml
looks like
concurrent = 1
check_interval = 0
[[runners]]
name = "PC123"
url = "http://1.2.3.4/ci"
token = "cd2b093adc5ca09ea41ee4eadb0752"
executor = "shell"
[runners.cache]
在提交中生成测试时,它将失败并
When the test is spawned on a commit it fails with
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
我想问题是URL中的主机名"localhost",它表示gitlab-runner所在的机器.在开始设置服务器时,我使用"localhost"作为服务器主机名.这可能不是最好的主意. :)
I suppose the problem is the hostname "localhost" in the URL, which refers to the machine gitlab-runner is on. When I set-up the server in the beginning I used 'localhost' as the servers hostname. This was probably not the best idea. :)
在此期间,我更改了此"localgit",但URL不会调整,但仍显示"localhost". (服务器已重启,gitlab-runner服务重启).
In the meantime I changed this "localgit", but the URL does not adjust, it still shows "localhost". (Server restarted, gitlab-runner servive restart).
服务器的主机名是否存储在主机名仍为localhost
时我克隆的原始存储库中的某个位置? .git/config
显示正确的IP:
Could it be that the server's hostname is stored somewhere in the original repo that I cloned when the hostname was still localhost
? .git/config
shows the correct IP:
[remote "origin"]
url = http://1.2.3.4/test/myproject.git
我发现了另一个问题( GitLab运行程序无法通过http克隆存储库)提到了一种将其他主机添加到gitlab-runner的config.toml
的方法,例如
I found another question (GitLab runner unable to clone repository via http) that mentions a way to add other hosts to gitlab-runner's config.toml
, like
[runners.docker]
extra_hosts = ["ci.mygitlab:127.0.0.1"]
但是我必须使用shell
执行程序,而不是docker.
But I must use the shell
executor, not docker.
推荐答案
As described here, the solution is to replace the entry host: localhost
in the Gitlab config file /home/git/gitlab/config/gitlab.yml
with the IP address of the host.
更换前:
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: localhost
更换后:
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: 10.0.1.2
这篇关于为什么gitlab-runner无法克隆我的项目? (不正确的主机名,无法连接)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!