Learn GITLAB-CI with Real Code Examples
Updated Nov 27, 2025
Explain
GitLab CI/CD automates software delivery pipelines.
Uses declarative YAML configuration in `.gitlab-ci.yml`.
Supports multiple stages like build, test, and deploy.
Integrates with GitLab repositories for seamless version control.
Facilitates parallel and sequential job execution for efficiency.
Core Features
Jobs - individual tasks executed in stages
Stages - sequential phases of a pipeline
Runners - agents that execute jobs
Artifacts - intermediate outputs saved between jobs
Variables - configurable parameters for jobs and pipelines
Basic Concepts Overview
Pipeline - sequence of stages executed for a commit
Job - individual unit of work within a stage
Stage - logical grouping of jobs (build, test, deploy)
Runner - agent that executes jobs
Artifacts - files preserved for later stages or downloads
Project Structure
.gitlab-ci.yml - pipeline configuration file
Scripts/ - optional shell, Python, or deploy scripts
Dockerfile - optional container image for jobs
Config files for environments and secrets
Directory structure reflects project artifacts for stages
Building Workflow
Define stages in `.gitlab-ci.yml`
Define jobs under each stage
Specify scripts, images, and dependencies for jobs
Assign runners to execute jobs
Trigger pipeline via commit, schedule, or manual action
Difficulty Use Cases
Beginner: Single-stage build and test pipeline
Intermediate: Multi-stage pipeline with artifacts
Advanced: Conditional jobs, caching, and parallel execution
Expert: Deployment pipelines with Kubernetes integration
Architect: Complex multi-project pipelines with triggers and schedules
Comparisons
GitLab CI vs Jenkins: integrated vs external tool
GitLab CI vs GitHub Actions: GitLab-native vs GitHub-native
GitLab CI vs CircleCI: self-hosted vs SaaS-centric
GitLab CI vs Travis CI: enterprise vs open-source focus
GitLab CI vs Azure Pipelines: GitLab integration vs Microsoft ecosystem
Versioning Timeline
2011 - GitLab CI introduced
2013 - Runner introduced for job execution
2015 - Auto DevOps pipelines introduced
2018 - Kubernetes integration improved
2023+ - Ongoing enhancements to pipelines, runners, and YAML features
Glossary
Pipeline - ordered stages executed per commit
Job - individual task within a stage
Stage - logical grouping of jobs
Runner - agent that executes jobs
Artifact - file or folder saved between jobs or for download