How to Install and Configure a GitLab Runner?
Leave a comment on How to Install and Configure a GitLab Runner?
We shall go through a step-by-step guide to install, register and finally configure a GitLab runner.
Installing GitLab runner manually via GNU or Linux
Step 1: Add the GitLab official repository
# Linux x86-64
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
# Linux x86
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-386
# Linux arm
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm
Step 2: Grant it access and permission to execute the task
sudo chmod +x /usr/local/bin/gitlab-runner
Step 3: Create a GitLab CI user for ease of access
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
Step 4: Install it and run it as a service
sudo gitlab-runner install --working-directory /home/project/gitlab-runner-builds --user <vps-user>
sudo gitlab-runner start
Step 5: The next step is to register the runner
How to register a Runner under GNU/Linux
Step 1: Run the following command exactly as given below
sudo gitlab-runner register
Step 2. Enter your GitLab instance URL (example provided)
Enter the gitlab-ci coordinator URL:
https://gitlab.com
Step 3. Enter the token you have when you registered the Runner
Enter the gitlab-ci token for this runner:
<your-token-id>
Your gitlab-ci token ID can be copied from your account:
Your-Project-repository→ Settings → CI/CD → Runners → Specific Runners → token-id
gitlab token
4. Enter a short context for the Runner (this can be changed later in GitLab’s UI)
Enter the gitlab-ci description for this runner:
[hostame] my-runner
5. Enter the Runner executor
In this case, we chose a shell:
Enter the following executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:
shell
Conclusion
In conclusion, GitLab Runner is a powerful tool for automating software testing and deployment. By following the step-by-step guide outlined in this article, you can install, register, and configure GitLab Runner manually on GNU/Linux, granting it the necessary permissions to execute tasks, and registering it with GitLab. With GitLab Runner up and running, you can enjoy a seamless continuous integration and deployment process, allowing you to focus on delivering high-quality software. Whether you are a developer, DevOps engineer, or IT professional, GitLab Runner is a valuable addition to your toolset.