How to Set Up a CI/CD Runner

Installing the CI Executor

The installation procedure varies by environment. This section covers Windows and Docker.

Windows-Based Executor

  1. Create a folder and download the installer
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
   mkdir D:\gitlab-runner
   cd D:\gitlab-runner
   ```

Download the installer from [Windows Runner](https://GitLab-runner-downloads.s3.amazonaws.com/latest/binaries/GitLab-runner-windows-amd64.exe) into `D:\\gitlab-runner`

1. Install

```bash
   .\gitlab-runner.exe install
   .\gitlab-runner.exe start
   ```

After installation, run `.\gitlab-runner.exe --version` to verify

![image](https://github.com/loustack17/loustack17.github.io/assets/33840759/c1028651-082c-46a3-be50-c4ee3885b5ad)

### Container-Based Executor

1. Install [Docker](https://docs.docker.com/get-docker/)
2. Run the Docker-based installation

```bash

   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
  1. Verify the installation
1
  docker exec -it gitlab-runner gitlab-runner --version

image

Registering the CI Executor

  • Runners come in 3 categories
  • Shared Runner: available to all projects
  • Group Runner: available to projects within a group
  • Specific Runner: available to a specific project

The registration process is largely the same across categories; this example uses a Shared Runner.

  1. Obtain the Runner Token
  • Shared Runner: log in → Admin Area → Overview → Runners

image

  • Specific Runner tokens are found in the project settings

image

  • Group Runner tokens are found in the group settings

image

  1. Run .\gitlab-runner.exe register or docker exec -it gitlab-runner gitlab-runner register to register the runner

  2. Fill in the registration details

  • Instance URL: the platform URL
  • Registration token: the Runner Token
  • Description: a description of the runner
  • Tags: labels for the runner
  • Maintenance note: maintenance information
  • Executor: how the runner executes jobs

image

  • If you want Docker-based CI/CD, choose docker as the executor
  • Here I wanted full control over the CI/CD environment, so I chose shell
  1. On success you will see the following

image

Check the runner status

image

References