[英]Why can't gitlab-runner clone my project? (Incorrect hostname, failed to connect)
I set-up a Gitlab server and need to run tests Windows using gitlab-runner.exe. 我设置了一个Gitlab服务器,需要使用gitlab-runner.exe运行Windows测试。
The gitlab-runner's executor is set to shell
, the config.toml
looks like 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]
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
I suppose the problem is the hostname "localhost" in the URL, which refers to the machine gitlab-runner is on. 我想问题是URL中的主机名“localhost”,它指的是gitlab-runner所在的机器。 When I set-up the server in the beginning I used 'localhost' as the servers hostname.
当我在开始时设置服务器时,我使用'localhost'作为服务器主机名。 This was probably not the best idea.
这可能不是最好的主意。 :)
:)
In the meantime I changed this "localgit", but the URL does not adjust, it still shows "localhost". 在此期间我改变了这个“localgit”,但URL没有调整,它仍然显示“localhost”。 (Server restarted, gitlab-runner servive restart).
(服务器重启,gitlab-runner servive重启)。
Could it be that the server's hostname is stored somewhere in the original repo that I cloned when the hostname was still localhost
? 可能是服务器的主机名存储在我主机名仍然是
localhost
时克隆的原始仓库中的某个位置? .git/config
shows the correct IP: .git/config
显示正确的IP:
[remote "origin"]
url = http://1.2.3.4/test/myproject.git
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 我发现了另一个问题( GitLab运行器无法通过http克隆存储库 )提到了一种将其他主机添加到gitlab-runner的
config.toml
,比如
[runners.docker]
extra_hosts = ["ci.mygitlab:127.0.0.1"]
But I must use the shell
executor, not docker. 但我必须使用
shell
执行器,而不是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. 如上所述这里 ,解决的办法是更换入口
host: localhost
在Gitlab配置文件/home/git/gitlab/config/gitlab.yml
与主机的IP地址。
Before replacing: 更换前:
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: localhost
After replacing: 更换后:
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: 10.0.1.2
If you've installed GitLab using the Omnibus package, you will need to ensure that external_url
in /etc/gitlab/gitlab.rb
is set to either the host machines hostname or IP address. 如果你使用的综合性软件包安装GitLab,你将需要确保
external_url
在/etc/gitlab/gitlab.rb
被设置为主机机器的主机名或IP地址。 Using localhost
seems to cause a conflict that results in the error that you describe. 使用
localhost
似乎会导致冲突,导致您描述的错误。 Here's an example: 这是一个例子:
## Correct
external_url 'http://192.168.0.2:8080'
## -or-
## external_url 'http://myhostname.com
## Incorrect
external_url 'http://localhost:8080'
Once you've corrected the external_url
, you'll need to reconfigure GitLab using the following command: 一旦纠正了
external_url
,就需要使用以下命令重新配置GitLab:
gitlab-ctl reconfigure
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.