Search code examples
gitlabgitlab-cigitlab-ci-runner

Gitlab Runner points to wrong URL


I have installed Gitlab-CE on a local Ubuntu Server (18.04) and am able to successfully access it through http://192.168.xxx.xxx/

I am trying to set up a CI/CD pipeline in a repository with a sample job at this point to just test if the pipeline runs successfully. This is my .gitlab-ci.yml:

stages:
    - build
    - test

build:
    stage: build
    script:
        - echo "Building"
        - mkdir build
        - touch build/info.txt
    artifacts:
        paths:
            - build/

test:
    stage: test
    script:
        - echo "Testing"
        - test -f "build/info.txt"

However, when I run the pipeline it fails with an error for unresolved host that points to a wrong URL - namely http://gitlab.example.com, instead of http://192.168.xxx.xxx/ . This is the error message:

Reinitialized existing Git repository in /builds/root/sast-dast-security-testing/.git/ fatal: unable to access 'http://gitlab.example.com/root/sast-dast-security-testing.git/': Could not resolve host: gitlab.example.com

I'm using a GitLab specific runner, which executes with Docker and use ruby:2.6 for as an image. This is the runner config.toml:

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "pipeline"
  url = "http://192.168.xxx.xxx/"
  token = "XXX"
  executor = "docker"
  dns = ["8.8.8.8"]
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "ruby:2.6"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0

I tried multiple suggested fixes, like adding the dns configuration line, but nothing worked.

Any help is appreciated!


Solution

  • I managed to fix my issue by changing the EXTERNAL_URL value in my /etc/gitlab/config.toml to http://192.168.xxx.xxx/ and then running gitlab-ctl reconfigure and gitlab-ctl restart. Apparently this was a misconfiguration while installing Gitlab and that's the URL that redirects the pipeline.