How to install and register a gitlab runner on Ubuntu OS
Ubuntu 20.04 (gitserver.stack.com)
Ubuntu 20.04 (gitrunner.stack.com)
Here in this article we will how we can install and register a gitlab runner with the gitlab server. We are going to use two Ubuntu servers. In one of the server we already have the gitlab server installation and setup done. We will be using the other server as gitlab runner and register it with the gitlab server.
Step1: Add Gitlab runner repository
As a first step in order to install the gitlab runner we first need to setup the repository from where we can download the gitlab runner package. We can setup the gitlab runner repository as shown below.
gitadmin@gitrunner:~$ curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 6885 100 6885 0 0 20863 0 --:--:-- --:--:-- --:--:-- 20863 Detected operating system as Ubuntu/focal. Checking for curl... Detected curl... Checking for gpg... Detected gpg... Running apt-get update... done. Installing apt-transport-https... done. Installing /etc/apt/sources.list.d/runner_gitlab-runner.list...done. Importing packagecloud gpg key... done. Running apt-get update... done. The repository is setup! You can now install packages.
Step2: Install Gitlab runner
Once the repository setup is completed we can install the gitlab-runner package as shown below.
gitadmin@gitrunner:~$ sudo apt-get install gitlab-runner
Step3: Get a Gitlab runner registration token
In order to register a server as gitlab runner with the gitlab server, we first need to get the registration token from the gitlab server which we can obtain by going into the Admin setting of the gitlab server and under the Overview – gitlab runner section you can get the registration token as shown in below image.
Token – szsVcAg_hVeGGFegWeyR
Step4: Register Gitlab runner
Registering a runner is the process that binds the runner with one or more GitLab instances. You can register multiple runners on the same host machine, each with a different configuration, by repeating the register command.
Once we have the token we can run the below gitlab-runner register command in interactive mode by providing the required details about the gitlab server and the registration token and other details as asked below.
gitadmin@gitrunner:~$ sudo gitlab-runner register Runtime platform arch=amd64 os=linux pid=4994 revision=febb2a09 version=15.0.0 Running in system-mode. Enter the GitLab instance URL (for example, https://gitlab.com/): http://gitserver.stack.com/ Enter the registration token: szsVcAg_hVeGGFegWeyR Enter a description for the runner: [gitrunner.stack.com]: Enter tags for the runner (comma-separated): gitrunner Enter optional maintenance note for the runner: Registering runner... succeeded runner=szsVcAg_ Enter an executor: parallels, ssh, docker+machine, docker-ssh+machine, custom, docker-ssh, virtualbox, kubernetes, docker, shell: docker Enter the default Docker image (for example, ruby:2.7): openjdk:11 Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Now, you can verify in the gitlab server runner section that the runner is registered as shown below.
Hope you enjoyed reading this article. Thank you..
Leave a Reply
You must be logged in to post a comment.