In this section, we will install and configure GitLab Runner - an essential agent for executing CI/CD jobs in GitLab.
Create directory and configuration file:
sudo mkdir -p /tools && vi tools/setup.sh
Add the following content to setup.sh:
#!/bin/bash
# Update package list
apt update -y
# Install GitLab Runner
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash
apt install gitlab-runner
# Check version
gitlab-runner --version
Check version to ensure successful installation:
gitlab-runner --version
sudo -i
su gitlab-runner
cd
Navigate to Runner settings:
Set up configuration:
fcj-lab-runner-be
Tags help identify which types of jobs the runner will process. For example: backend jobs, frontend jobs.
# Register runner with token
gitlab-runner register --url https://gitlab.com --token [your-token]
# Enter information when prompted
- URL: https://gitlab.com
- Name: fcj-lab-runner-be
- Executor: shell
# Run in background
nohup gitlab-runner run > start-runner-be.txt 2>&1 &
# Check logs
tail -f start-runner-be.txt
To handle jobs efficiently, we need to create a separate runner for frontend tasks.
Repeat the above steps with these details:
fcj-lab-runner-fe
fcj-lab-runner-fe
Check runners list: