Installing GitLab on Your Own Server (Part 3) – Install gitlab-runner

I want to use the integrated CI/CD feature of GitLab so I have to install gitlab-runner as described in the documentation.

The installation does not need to be on the same host as GitLab — it is recommended not to do so.

After installing the gitlab-runner I register a runner with GitLab in order to use it.

The easiest way to register a runner is by installing it interactively:

sudo gitlab-runner register

A complete documentation is available on the GitLab site.

I also want to build docker images with a runner so I have to register the runner in a special way (as documented).

I register runners at different levels. First I register shared runners that are available for all projects on the server (configurable in the Admin Area/Runners). Additionally I register runners for a groups (configurable in Settings CI/CD). Additionally it is possible to install a runner only for a single project. I do not need this.

To use a runner you need to set up Auto DevOps (which I do not explain here) or add a .gitlab-ci.yml.

A documentation of the .gitlab-ci.yml format is available at the GitLab site.

Please note that by default the number of concurrent jobs on a single server is limited to 1 — even if you register multiple runners. I want to run multiple jobs concurrently so I edit the file /etc/gitlab-runner/config.toml manually and change the value of the parameter concurrent to a higher number (to 2 to run 2 jobs concurrently per registered runner). The correct value for a system depends on the number of cores available and how many cores are used by the builds.

Now if I check in a .gitlab-ci.yml with your repository then a runner starts a CI build.

Next I will show how to import a project from GitHub to my new GitLab server.

Parts

References

2 thoughts on “Installing GitLab on Your Own Server (Part 3) – Install gitlab-runner

  1. Pingback: Installing GitLab on Your Own Server (Part 1) – Installation | Blog at sw4j.de

  2. Pingback: Installing GitLab on Your Own Server (Part 2) – Configure NGINX Reverse Proxy | Blog at sw4j.de

Leave a Reply

Your email address will not be published. Required fields are marked *