Gitlab Continuous Integration & Delivery (Part-2)

Mahdieh Asiyaban
3 min readOct 3, 2020

--

image credit: gitlab.com

In the previous section (Part-1), we saw how to install the Gitlab.

To remind you, we are in the fifth section (Installation of Gitlab Runner)

Let’s start this section with a good question.

What is Gitlab-Runner and Why we need it for the CI / CD process?

Let me give you an example:

Gitlab-runner is like a postman, It receives the letters and sends them to the address written on the letter. And it does not matter what is written in the letter. The postman's job is to read the address and send the letter to the destination. That’s all the GitLab-runner does.

Interesting, does not it?

Now the official definition is that GitLab Runner is the open-source project that we need it to run the jobs and send the results back to GitLab.

Install Gitlab-Runner:

  1. Add GitLab’s official repository:
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash

2. Install GitLab-runner:

sudo yum install gitlab-runner

Wait for the installation process to complete.

After installation, we want to register the Gitlab-runner for our project.

Register Gitlab-Runner

  1. First stop GitLab-runner:
sudo gitlab-runner stop

2. Run the following command:

sudo gitlab-runner register

At this point, we need some information.
First, go to the Gitlab panel and click on the project you have already created.

Then go to the following path:

Settings --> CI / CD --> Runners (click on expand button)

3. In this step, copy the URL specified and enter it in the terminal to continue registering.

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com)

4. In this step, copy the token on the runner page and enter it in this field.

Please enter the gitlab-ci token for this runner:
(for exmaple: 4yYBiYbo_LP2HsGe)

5. In this section, enter a custom description.

Please enter the gitlab-ci description for this runner:
(for example: project-test-descrptipn)

6. Then enter a few tags as desired:

Please enter the gitlab-ci tags for this runner (comma separated):
(for exmaple: package, build, delploy)

7. In this step we can select the Executor Shell, type the shell according to the following command:

Please enter the executor: custom, docker, docker-ssh, parallels, shell, ssh, virtualbox, docker+machine, docker-ssh+machine, kubernetes:
(for example: shell)

Finally, you will see a successful message:

Registration runner... succeeded

8. Now enter the following command to start Gitlab-runner:

sudo gitlab-runner start

9. And you can check the status of the Gitlab-runner to make sure everything is fine:

sudo gitlab-runner status

10. Go to the Gitlab panel again and refresh the runner page to make sure the runner is activated with a green circle.

This part is over and we go to the next part.

--

--