8

I set-up a Gitlab server and need to run tests Windows using gitlab-runner.exe.

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

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. :)

In the meantime I changed this "localgit", but the URL does not adjust, it still shows "localhost". (Server restarted, gitlab-runner servive restart).

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

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"]

But I must use the shell executor, not docker.

Joe
  • 6,758
  • 2
  • 26
  • 47

2 Answers2

3

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.

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
Mahdi Youseftabar
  • 2,273
  • 1
  • 22
  • 29
Joe
  • 6,758
  • 2
  • 26
  • 47
  • this is a solution for local git or anything personal sized but I have the issue accessing my corporate gitlab server, putting the IP is not a solution as we rely on DNS. any ID? I don't have the issue with a normal runner, only with my DinD runner. I just had to add the dns search param in the config.toml – TecHunter Feb 16 '18 at 15:29
  • Putting the hostname there instead of the IP also works. – Joe Feb 16 '18 at 21:14
  • I am using windows, where should I see this `/home/git/gitlab/config/gitlab.yml` ?in windows environment – MuntingInsekto Aug 20 '19 at 10:48
  • Windows for the server or the gitlab-runner? – Joe Aug 24 '19 at 04:29
2

Omnibus package installation

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. Using localhost seems to cause a conflict that results in the error that you describe. 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:

gitlab-ctl reconfigure
Community
  • 1
  • 1
JTW
  • 3,546
  • 8
  • 35
  • 49