GitLab Runner

GitLab Runner is the open source project that is used to run your jobs and send the results back to GitLab. It is used in conjunction with GitLab CI, the open-source continuous integration service included with GitLab that coordinates the jobs.


Note

For this guide you should be familiar with the basic concepts of

Prerequisites

GitLab project

You need to have a project in GitLab that you want to deploy using GitLab Runner.

For further information please refer to the official GitLab Runner docs

Obtain registration token

To create a specific Runner without having admin rights to the GitLab instance, visit the project you want to make the Runner work for in GitLab:

Go to Settings > CI/CD to obtain the token

Installation

Download latest version

Use wget to download the latest version of GitLab Runner:

[isabell@stardust ~]$ wget -O /home/$USER/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64

Make it executable:

[isabell@stardust ~]$ chmod +x /home/$USER/bin/gitlab-runner

Optional check runner version:

[isabell@stardust ~]$ /home/$USER/bin/gitlab-runner -v

Create working directory

Create a working directory for the runner:

[isabell@stardust ~]$ mkdir /home/$USER/gitlab-runner

Register the runner

Note

You need your registration token you copied above.

This basic setup uses the shell executor. See: GitLab Runner Executors

[isabell@stardust ~]$ /home/$USER/bin/gitlab-runner register

Configure the supervisord service

Create a shell script (e.g. /home/$USER/bin/gitlab-runner.sh) that keeps the call for the runner:

#!/bin/bash
/home/$USER/bin/gitlab-runner run --working-directory=/home/$USER/gitlab-runner/

Make it executable:

[isabell@stardust ~]$ chmod +x /home/$USER/bin/gitlab-runner.sh

Create supervisord ini (e.g. /home/$USER/etc/services.d/gitlab-runner.ini:

[program:gitlab-runner]
command=%(ENV_HOME)s/bin/gitlab-runner.sh

After creating the configuration, tell supervisord to refresh its configuration and start the service:

[isabell@stardust ~]$ supervisorctl reread
SERVICE: available
[isabell@stardust ~]$ supervisorctl update
SERVICE: added process group
[isabell@stardust ~]$ supervisorctl status
SERVICE                            RUNNING   pid 26020, uptime 0:03:14
[isabell@stardust ~]$

If it’s not in state RUNNING, check your configuration.


Tested with GitLab Runner 11.1.0, Uberspace 7.1.7.0

Written by: Michael Stötzer <hallo@bytekeks.de>