Search code examples
gitlabgitlab-cigitlab-ci-runner

gitlab-ci.yml fatal: unable to access http://gitlab-ci-token


I am new to gitlab CI/CD and I'm struggling to figure this out.

All I want to do is when I push to dev branch I want my react app to be built and the folder ./build to be pushed through SSH to my dev server.

Here is what I did so far, including a screenshot of the error message I get.

This is my gitlab-ci.yml

image: node:latest

cache:
  paths:
    - node_modules/

build_dev:
  stage: build
  environment: Development
  only: 
    - dev
  script:
    - ls
    - npm install
    - npm run build
  artifacts:
    paths:
      - build/
      - ecosystem.config.js

deploy_dev:
  stage: deploy
  environment: Development
  only:
    - dev
  script:
    - rsync -r -a -v -e ssh --delete "./build" root@dev.teledirectasia.com:/var/www/gitlab/${CI_PROJECT_NAME}
    - rsync -r -a -v -e ssh --delete "./ecosystem.config.js" root@dev.teledirectasia.com:/var/www/gitlab/${CI_PROJECT_NAME}/
    - ssh root@dev.teledirectasia.com "cd /var/www/gitlab/${CI_PROJECT_NAME} && pm2 start ecosystem.config.js"

I don't know why I am getting this output with job failed

enter image description here


Solution

  • This is a DNS problem. Your runner cannot resolve the hostname of the GitLab server - gitlab.teledirectgroup.com. Did you set the GitLab hostname if your local workstation's host file manually, or did you set it up in a DNS server as a 'proper' hostname?

    If you set up the hostname in a DNS server then the solution may be as simple as adding the DNS server to /etc/resolv.conf on the runner. However, if you just set the GitLab hostname in your workstation's hosts file then you'll need to set it in the runner's /etc/hosts file, too. It's hard to say what the exact solution is without knowing how you set up the GitLab hostname in the first place.