How to Install and configure GitLab runner on centos 7

Method To Install and configure GitLab runner on centos 7

Introduction:

GitLab Runner is an application that works with GitLab CI/CD to run jobs in a pipeline. GitLab Runner is open-source and written in Go. It can be run as a single binary; no language-specific requirements are needed. GitLab Runner can also run inside a Docker container or be deployed into a Kubernetes cluster.

Installation Procedure:

Step 1 : Check the installed OS version by using the following command

linuxhelp@linuxhelp:~$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"

Step 2: Login to your Gitlab account and go inside any project Snap1

Step 3: Navigate the project to find the settings and move to the CI/Cd section

Step 4: Follow the instruction given under the specific runners sections

Step 5 : To install GitLab Runner, Add the official GitLab repository

root@linuxhelp: curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh" | sudo bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6904  100  6904    0     0  11167      0 --:--:-- --:--:-- --:--:-- 11153
Detected operating system as centos/7.
Checking for curl...
Detected curl...
Downloading repository file: https://packages.gitlab.com/install/repositories/runner/gitlab-runner/config_file.repo?os=centos&dist=7&source=script
done.
Installing pygpgme to verify GPG signatures...
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.piconets.webwerks.in
 * epel: mirrors.nipa.cloud
 * extras: mirrors.piconets.webwerks.in
 * updates: centosa7.centos.org
gitlab-ce/x86_64/signature                                                                                                                                                                 |  862 B  00:00:00
gitlab-ce/x86_64/signature                                                                                                                                                                 | 1.0 kB  00:00:00 !!!
runner_gitlab-runner-source/signature                                                                                                                                                      |  862 B  00:00:00
runner_gitlab-runner-source/signature                                                                                                                                                      |  951 B  00:00:00 !!!
Package pygpgme-0.3-9.el7.x86_64 already installed and latest version
Generating yum cache for runner_gitlab-runner...
Generating yum cache for runner_gitlab-runner-source...

The repository is setup! You can now install packages.

Step 6 : Install the latest version of GitLab Runner

root@linuxhelp:~# sudo yum install gitlab-runner
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: mirrors.nipa.cloud
 * extras: centos.excellmedia.net
 * updates: centosv8.centos.org
Resolving Dependencies
--> Running transaction check
---> Package gitlab-runner.x86_64 0:14.3.2-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================
 Package                                             Arch                                         Version                                        Repository                                                  Size
Installing:
 gitlab-runner                                       x86_64                                       14.3.2-1                                       runner_gitlab-runner                                       433 M


Total download size: 433 M
Installed size: 472 M
Is this ok [y/d/N]: y
Downloading packages:
gitlab-runner-14.3.2-1.x86_64.rpm                                                                                                                                                          | 433 MB  00:00:47
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : gitlab-runner-14.3.2-1.x86_64                                                                                                                                                                  1/1
revision=e0218c92 version=14.3.2
INFO: Docker installation not found, skipping clear-docker-cache
  Verifying  : gitlab-runner-14.3.2-1.x86_64                                                                                                                                                                  1/1
Installed:
  gitlab-runner.x86_64 0:14.3.2-1
Complete!

Step 7 : Now its time to register the runner To register a runner under Linux: Run the following command:

root@linuxhelp:~# sudo gitlab-runner register
Enter the GitLab instance URL (for example, https://gitlab.com/):
http://192.168.6.115/
Enter the registration token:
azCS4D5nSBbLE9zjJ-R3
Enter a description for the runner:
[linuxhelp]: Ci
Enter tags for the runner (comma-separated):
cui pipeline
Registering runner... succeeded                     runner=azCS4D5n
Enter an executor: kubernetes, custom, docker, shell, docker+machine, docker-ssh+machine, docker-ssh, parallels, ssh, virtualbox:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!.

With this installation and configuration of Gitlab runner on centos 7 comes to end.

Tag : gitlab CentOS
FAQ
Q
How do I disable GitLab runner?
A
On the top bar, select Menu > Projects and find your project. On the left sidebar, select Settings > General. Expand Visibility, project features, permissions. In the Repository section, turn on or off CI/CD as required.
Q
Where does GitLab runner store files?
A
The uploads are stored by default in /home/git/gitlab/shared/artifacts . Save the file and restart GitLab for the changes to take effect
Q
How do you check if a GitLab runner is running?
A
When you execute gitlab-runner commands, you see the mode it is running in: $ gitlab-runner run INFO[0000] Starting multi-runner from /Users/ayufan/. gitlab-runner/config.
Q
What is GitLab runner used for?
A
GitLab runner is a build instance that is used to run the jobs over multiple machines and send the results to GitLab
Q
Why can’t I run more than one instance of GitLab Runner?
A
we can run, but not share the same config.toml file.