Skip to main content

GitLab runner installation

This document describes installation steps for installing and registering GitLab runners.

We use GitLab runners for compiling and releasing new versions of project bundle, releasing notes, etc.

Note: Lines starting with symbol $ are commands for shell.


Variables used in this guide:

  • ${EXECUTOR} - executor used to run builds. E.g.: docker, shell, ssh,...
  • ${SERVER_NAME} - stands for server name
  • ${KEY} - token for GitLab runner, needed for registering
  • ${URL} - url to your GitLab instance. E.g.: https://gitlab.company.com/

Add GitLab's official repository

Adding GitLab's repository can be done with command:

  • For Debian/Ubuntu/Mint:
    • $ curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
  • For RHEL/CentOS/Fedora:
    • $ curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash

Install the latest version of GitLab Runner

After the repository is added, GitLab runner can be simply installed with:

  • For Debian/Ubuntu/Mint:
    • $ sudo apt-get install gitlab-runner
  • For RHEL/CentOS/Fedora:
    • $ sudo yum install gitlab-runner

Add gitlab-runner to the docker group

GitLab Runner needs to have permissions to be able to run docker commands.

  • $ usermod -aG docker gitlab-runner

Register the runners

You need to bind a runner with a GitLab instance. This can be done with:

  • $ gitlab-runner register --name ${SERVER_NAME-EXECUTOR} --tag-list "${SERVER_NAME},${EXECUTOR}" --executor ${EXECUTOR} --locked=false --url ${URL} -r ${KEY}

Configure runner volume

Docker needs volume setting for creating other containers inside the container, this can be done with changing volume setting in config file

  • Modify the line volumes in this file /etc/gitlab-runner/config.toml
    • volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]

Troubleshooting

Trust self-signed certificates

If you need to use self-signed certificates for registering the runners:

  1. ​get certificates and copy them to:
​/etc/pki/ca-trust/source/anchors/
  1. run: $ update-ca-trust

SSL certificate problem

If you are getting error: SSL certificate problem: self signed certificate in certificate chain

  • Insert this line into /etc/gitlab-runner/config.toml under docker runner config [[runners]]
    • pre_clone_script = "git config --global http.https://gitlab.sslVerify false"

HTTP proxy error

If docker daemon cannot connect to registry and you are getting similar error: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) you need to set up proxy settings for docker

  • This is described here section Docker and proxy settings