Docker runner doesn't pick up jobs

Hi. I’m trying to setup a simple CI/CD pipeline to deploy changes from a specific branch (test branch for now) and it doesn’t work because of some problems with runners.

I’m trying to create a self-hosted Docker runner on my Ubuntu Desktop 23.10

  1. I start with going to Settings - CI/CD - Runners - Create new runner within my project. There are no project or shared runners at this point. I created a new project runner.

I got

As far as I understand, I should now install the local runner on my machine (I’m going with a self-hosted runner for now). I’m going to use Docker, so I’m using the command from the docs:

docker run -d --name gitlab-runner --restart always \
  -v /srv/gitlab-runner/config:/etc/gitlab-runner \
  -v /var/run/docker.sock:/var/run/docker.sock \
  gitlab/gitlab-runner:latest

This pulls the image and creates a gitlab-runner container successfully.

As far as I understand, now I should go inside the container and run the command from the screenshot above, right? So I’m doing this:

docker exec -it gitlab-runner bash

gitlab-runner register  --url https://gitlab.********.com  --token glrt-***********************

This is my /etc/gitlab-runner/config.toml inside the container:

And I can see a success pop-ups on the gitlab runner creation page

I’m going back to the runner page and I can see my runner with a green mark
image

So it should be fine, right?

In the Variables section I registered the needed variables to connect to the Dev server via SSH:

I created a simple .gitlab-ci.yml file in the root of my project to test the pipeline is working:

image: node:20

stages:
  - deploy

pages:
  stage: deploy
  before_script:
    - 'command -v ssh-agent >/dev/null || ( apk add --update openssh )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan $VM_IPADDRESS >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
  script:
    - ssh $SSH_USER@$VM_IPADDRESS "hostname && echo 'Welcome!!!' > welcome.txt"
  artifacts:
    paths:
      - public
  only:
    - feature/ci

I created a commit in my feature/ci branch and pushed to GitLab. And the pipeline stuck.


I re-created and re-configured everything multiple times but the pipeline never run.

P.S. Also I can see some logs running docker logs gitlab-runner, see the screenshot in the 1st response below.

Also, I can see some errors running docker logs gitlab-runner

Hi,

By default, GitLab Runners will pick up only jobs that have the same tag, unless you check the option to run untagged jobs as described here. So, I’d start with adding a tag to your CI Config:

default:
  tags:
    - admin

Generally, tags are very useful to define which jobs / pipelines should be run with which runner (executor), as it can happen that a job has some special requirements in order to run (e.g. different host / platform, etc).

Thank you, this solved my issue!

PS. And I already set my first working deployment pipeline using gitlab CI/CD, I’m happy :slight_smile:

1 Like