Deploy CI/CD Pipeline on Personal VPS with Jenkins and GitLab Runner: Detailed Guide for Small Businesses
A detailed guide to deploying CI/CD pipelines on a personal VPS using Jenkins and GitLab Runner, optimizing software development workflows for small businesses with low cost and...
Introduction to CI/CD and Benefits for Small Businesses
CI/CD (Continuous Integration/Continuous Deployment) is a critical component of modern software development, automating the build, test, and deployment of code. For small businesses, deploying CI/CD on a personal VPS offers an effective solution to reduce costs and accelerate product development.
In this guide, we will deploy a CI/CD pipeline using Jenkins and GitLab Runner on a personal VPS, enabling automation from code push to application deployment in production environments.
Requirements and Environment Preparation
To deploy the CI/CD pipeline, you will need:
- A personal VPS (minimum 2GB RAM, 2 CPU cores)
- Linux operating system (Ubuntu 20.04/22.04 or CentOS 8)
- Git installed on the VPS
- SSH access to the VPS
- GitLab account (can use GitLab.com or self-hosted)
Setting Up Jenkins on the VPS
To install Jenkins, follow these steps:
sudo apt update
sudo apt install openjdk-11-jdk -y
sudo wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo "deb https://pkg.jenkins.io/debian-stable binary/" > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins -y
sudo systemctl start jenkins
sudo systemctl enable jenkins
After installation, access http:// to retrieve the initial password and complete setup.
Setting Up GitLab Runner
GitLab Runner enables execution of CI/CD jobs from GitLab. To install it, run the following command on the VPS:
sudo curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash
sudo apt install gitlab-runner -y
sudo gitlab-runner register
During registration, enter the GitLab URL, runner token, and other details. Choose the executor as shell or docker based on your needs.
Configuring the CI/CD Pipeline on GitLab
In your GitLab repository, create a .gitlab-ci.yml file with the following example content:
stages:
- build
- test
- deploy
build_job:
stage: build
script:
- echo "Building the application..."
- make build
test_job:
stage: test
script:
- echo "Running tests..."
- make test
deploy_job:
stage: deploy
script:
- echo "Deploying to production..."
- scp -r ./dist/* user@your-vps-ip:/var/www/html/
GitLab will automatically execute the jobs according to this configuration with each new commit.
Testing and Troubleshooting
To verify the pipeline, push a new commit to the repository. If errors occur, check the logs in GitLab CI/CD.
Common issues include:
- SSH access denied: verify SSH keys on the VPS and GitLab
- GitLab Runner not running: run
sudo gitlab-runner status - Connection issues to VPS: check firewall and port settings
References
For additional information, refer to the following resources:
High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache
Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.
VPS-4E
10% VAT included
- CPU: 4 vCPU
- RAM: 8 GB
- SSD: 50 GB NVMe
