NOTE: The tutorial assumes that you have basic knowledge on CI/CD. If you aren't aware of it, then we recommend you to look here
GitLab runner is a build instance which is used to run the jobs over multiple machines and send the results to GitLab and which can be placed on separate users, servers, and local machine. You can register the runner as shared or specific after installing it.
Gitlab.com by default provides free shared runner services for CI pipeline with certain minutes, post which we will need to buy the minutes for organisation / project depeneding on your needs. Each time the minutes expire we will need to buy the pipeline minutes again. If the pipeline is setup for testing development process, then think of the number of times the pipeline would be triggered? And the minitues could expire within days, if the script takes longer time. In such case we would be spending a lot of money in buying the CI/CD minutes.
To avoid this, Gitlab also provides a way for us to install runners on our custom servers / host machines and the jobs would execute in them.
Now let us see how we can install gitlab runners and use them for our jobs. In this guide we would be setting up a shared runners as a docker service. There are multiple other kind of setup services available in the official docs. Check them here - Installing Runners
Before you begin, ensure Docker is installed on your machine.
And Obtain a token:
Overview > Runners
Settings > CI/CD
and expand the Runners
sectionSettings > CI/CD
and expand the Runners
sectionNOTE: For this tutorial we would be using group runner
To run gitlab-runner inside a Docker container, you need to make sure that the configuration is not lost when the container is restarted. For this purpose we will be using the local system for mounting all the data volumes.
Use the following command to install runner as a docker service :
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
The final step is to register a new runner. The GitLab Runner container doesn’t pick up any jobs until it’s registered.
docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register
gitlab-ci coordinator URL
) - When registering a runner on GitLab.com, the gitlab-ci coordinator URL
is https://gitlab.com
..gitlab-ci.yml
.We should now be able to see our runners available under Settings > CI/CD
and make sure it is selected, so that it picks all our jobs and does the rest of the magic.
NOTE: This docs is curated one for quick start and which worked for us. The same information with in deail docs could be found in the offical Gitlab Runners setup section