Configure GitLab Runner Setup
This document provides a step-by-step guide to configure GitLab Runner on an Ubuntu system.
CMDS Overview
#!/bin/bash
# Update the package list
sudo apt update -y
# Install prerequisites
sudo apt install -y curl
# Install GitLab Runner
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash
sudo apt-get install gitlab-runner
# Display available versions of GitLab Runner
apt-cache madison gitlab-runner
# Display the installed GitLab Runner version
sudo gitlab-runner -version
# Display the status of GitLab Runner
sudo gitlab-runner status
# Start GitLab Runner service
sudo gitlab-runner start
# Enable GitLab Runner service to start on boot
sudo gitlab-runner enable
# Verify GitLab Runner service
sudo gitlab-runner verify
# Grant sudo privileges to gitlab-runner
echo "gitlab-runner ALL=(ALL:ALL) ALL" | sudo tee -a /etc/sudoers.d/sudoers
echo "gitlab-runner ALL=(ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers.d/sudoers
# Register the runner, replace the variables with actual values
sudo gitlab-runner register \
--non-interactive \
--url "https://example.in/" \
--registration-token "??????" \
--executor "shell" \
--tag-list "tag1,tag2" \
--description "Shell Runner"Steps Explained
-
Update Package List:
sudo apt update -yUpdates the package list to ensure the latest versions are available.
-
Install Prerequisites:
sudo apt install -y curlInstalls
curl, which is required to download the GitLab Runner installation script. -
Install GitLab Runner:
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash sudo apt-get install gitlab-runnerDownloads and runs the GitLab Runner installation script, then installs GitLab Runner.
-
Display Available Versions:
apt-cache madison gitlab-runnerLists all available versions of GitLab Runner.
-
Display Installed Version:
sudo gitlab-runner -versionShows the currently installed version of GitLab Runner.
-
Display Runner Status:
sudo gitlab-runner statusChecks the current status of the GitLab Runner service.
-
Start GitLab Runner Service:
sudo gitlab-runner startStarts the GitLab Runner service.
-
Enable GitLab Runner Service on Boot:
sudo gitlab-runner enableEnsures the GitLab Runner service starts automatically on system boot.
-
Verify GitLab Runner Service:
sudo gitlab-runner verifyVerifies the GitLab Runner service is running correctly.
-
Grant Sudo Privileges to GitLab Runner:
echo "gitlab-runner ALL=(ALL:ALL) ALL" | sudo tee -a /etc/sudoers.d/sudoers echo "gitlab-runner ALL=(ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers.d/sudoersGrants the
gitlab-runneruser full sudo privileges with and without password prompts. -
Register the GitLab Runner:
sudo gitlab-runner register \ --non-interactive \ --url "https://example.in/" \ --registration-token "??????" \ --executor "shell" \ --tag-list "tag1,tag2" \ --description "Shell Runner"Registers the GitLab Runner with a GitLab instance using the provided URL and registration token.
Additional Commands
Runner Configuration File:
/etc/gitlab-runner/config.tomlThe main configuration file for GitLab Runner.
By following these steps, you can set up and configure a GitLab Runner to automate your CI/CD pipelines efficiently.