Updated April 15, 2023
Introduction to Gitlab runner register
Gitlab runner register is defined as a process that enables binding of runners with one or more than one instance. The runner is defined as an application that facilitates the running of jobs in a pipeline. These application needs to be downloaded and installed on the infrastructure that is owned or managed. For security reasons, it is advised to install the runner application on another device different from the one that hosts the Gitlab instance. The runner application is open-source and is written in Go programming language, which is a single binary file where there is no requirement of language-specific requirements. In this article, we will look at the step post the installation that is getting the runner registered, and also a depth look at the elements that make the runner register possible.
Overview on Gitlab runner register
Gitlab runners as an application set up the communication between the Gitlab instance and the machine where the runner is installed. The processing of the job happens in the same machine where the Gitlab runner is installed, but in addition, one can run jobs in the container like Kubernetes, auto-scaled instances, etc. While a runner is registered one must choose an executor. An executor is that part of the flow that decides where each job runs. With a handful of configurations, one can install the runner on a virtual machine and use the other virtual machine as an executor. Alternatively, with Gitlab runner installed in Docker, one would need to use the docker executor for running the jobs. The command that enables the registration of the Gitlab runner is as follows:
With the above command, various options are present to achieve some dynamism and help achieve a particular goal. After execution of the command, it adds an entry in the configuration file. With a single installation, one can have multiple configurations and with each execution of the command, a new configuration entry is added without removing the previous one. The 2 options that are provided to achieve the desired results are:
This is a by default mode that is used while executing the Gitlab runner register command. With the command, one can input a lot of arguments viz. name of the runner, CI server URL, registration token, etc. These arguments can be either entered as an argument in the command-line interface or through setting the environment variable. to understand the exhaustive list of the options one can execute GitLab-runner register –help
This is a mode that has to be manually turned on bypassing the command –non-interactive while executing the Gitlab runner register command. With the command, one can input a lot of arguments same as that of the interactive one viz. name of the runner, CI server URL, registration token, etc. These arguments can be either entered as an argument in the command-line interface or through setting the environment variable. The additional environment variable that would be used here is REGISTER_NON_INTERACTIVE. The same exhaustive list of interacted registration applies here as well.
Remember from the last paragraph, that one runner install can enable multiple configurations under the single configuration file. This is a command that is used for listing down all the runners that are saved in the configuration file that uses the TOML format. This format enables minimal configuration file format which makes it easier to comprehend due to obvious semantics.
GitLab runner register verify
To enable developers to allow checking if the runners that are registered can connect to the Gitlab. Though this command doesn’t allow verification if a runner is being used by the Gitlab Runner service. If one needs to remove an old runner that has been removed from Gitlab, one will have to execute the command: GitLab-runner verify –delete
gitlab runner register unregister
Another feature that proves to be quintessential for the Gitlab runner application is the ability to unregister any registered runner that has been performed by the commands discussed earlier. This command uses a Runners API, which is an Application programming interface for registering or unregistering runners in Gitlab. The command would need either the entire URL and the token of the runner that needs to be unregistered or the name of the runner. This command also provides an option –all-runners which allows unregistering of all attached runners. One would be wondering how we can get the list or details of the runners! For this, we have discussed the GitLab-runner list command that would show the list of all runners and we can choose the one that is of our concern. Below are the commands:
Using URL and token
gitlab-runner unregister --url <URL of the runner> --token <Token of the runner>
gitlab-runner unregister --name <Name of the runner>
Below is the Step by step process to install Gitlab Runner (in Windows)
- Download binary exe file from Gitlab official page as per the system characteristics.
- Create a folder that will contain the exe file and copy the downloaded exe file.
- Open a command prompt in administrator mode and navigate to the location where the exe file is saved.
- Execute command GitLab-runner.exe install.
- Once installed one can check the version by running GitLab-runner –version.
GitLab Runner commands
We discussed a lot of Gitlab runner commands in our earlier paragraphs, and hence we would need to classify them and thus, we have 3 categories:
- Commands related to Registration: gitlab-runner register, gitlab-runner list, gitlab-runner verify, gitlab-runner unregister.
- Commands related to service: gitlab-runner install, gitlab-runner uninstall, gitlab-runner start, gitlab-runner stop, gitlab-runner restart, gitlab-runner status
- Commands related to run: gitlab-runner run, gitlab-runner run-single, gitlab-runner exec.
- Internal commands: gitlab-runner artifacts-downloader, gitlab-runner artifacts-uploader, gitlab-runner cache-archiver, gitlab-runner cache-extractor
With this article, we have looked at the 360-degree aspect of the Gitlab runner register and in addition, looked at some of the other commands that contribute to the success of Gitlab runner as an application.
We hope that this EDUCBA information on “Gitlab runner register” was beneficial to you. You can view EDUCBA’s recommended articles for more information.