Introduction
In this article we will understand what is GitLab Runner, how to setup and further we will learn to use in CI/CD pipeline.
What is GitLab Runner
GitLab runner is an application which helps to execute jobs in pipeline for CI/CD.
When we run pipeline all execution of the script and task happens through GitLab Runner. It can be installed on On-premise or on Cloud Infrastructure.
Why GitLab Runner
This is helpful when we want to configure our own build machine which further can be used for all the CI/CD pipeline.
Types of Runner
GitLab Runner --> Use by Tagged CI
Runner SaaS --> Use by untagged CI
Runner Scope
Runners are available based on who you want to have access:
Shared Runner --> Available for All GitLab Groups & Projects and Groups
Group Runner --> Available for All GitLab Projects and Sub Groups in a Group
Specific Runner --> Specific to One Project
Architecture
How to Setup GitLab Runner
To setup GitLab Runner we need to first Install Runner and then register with GitLab.
Install Runner
Step 1: GitLab Project Settings -> CI / CD -> Runners section, and clicking Show runner installation instruction.
Step 2: Download the GitLab Runner exe specific to required OS.
Step 3: Copy downloaded GitLab Runner exe to System where you want to configure the Runner.
Example: Like
C:\GitLab-Runner
Step 4: Run the CMD as Admin/Elevated User
cd C:\GitLab-Runner
.\gitlab-runner.exe install
Step 5: Verify is the service Installed after few minutes
Step 6: Start the service
Register Runner
After successful installation of runner now we need to register it with GitLab Project.
Follow this link for specific OS --> Register Runner
Step 1: Run the following command
.\gitlab-runner.exe register
Step 2: Enter the GitLab Install detail can be found
GitLab --> Setting --> CI/CD --> Runner
Step 3: Enter Tags for the Runner --> windows-demo
Step 4: Enter the Runner description --> Demo test
Step 5: Enter Executor --> Shell
Verify Runner
After the successful configuration you will see the Runner detail in the GitLab Portal.
How to use in YAML Pipeline
Now we can use this Runner in our YAML pipeline after defining the Tag at Job level.
stages:
- build
- package
- deploy
build-job:
stage: build
tags:
- windows-demo
script:
- write-host "Hello world"
Comments