TL;DR: If you are new to GitLab CI/CD, build these five pipeline patterns in order. They teach you almost everything you need for real projects.
1. The "hello pipeline"
Start with the smallest possible pipeline.
stages:
- build
build-job:
stage: build
script:
- echo "Building"
Why it matters: it proves your project, runner and YAML all work.
2. Multi-stage pipeline
stages:
- build
- test
- deploy
build-job:
stage: build
script:
- echo "Compiling..."
test-job:
stage: test
script:
- echo "Running tests..."
deploy-job:
stage: deploy
script:
- echo "Deploying..."
Stages run in order. Jobs in the same stage run in parallel.
3. Passing files with artifacts
build-job:
stage: build
script:
- echo "build output" > build.txt
artifacts:
paths:
- build.txt
expire_in: 1 hour
Later jobs can now use build.txt.
4. Controlling jobs with rules
deploy-job:
stage: deploy
script:
- echo "Deploying to production"
rules:
- if: $CI_COMMIT_BRANCH == "main"
This deploys only from the main branch.
5. Running jobs in Docker
test-job:
stage: test
image: node:20
script:
- node --version
Docker keeps your environment the same every time.
What should you learn next?
After these five, try CI/CD variables for secrets, caching, the GitLab Container Registry, reusable templates with include, and deploying with Terraform or Kubernetes.
I turned this learning path into a hands-on course with 50 practical tasks, from beginner to advanced: https://www.udemy.com/course/gitlab-ci-cd-hands-on-build-your-own-50-gitlab-pipelines/
What was the first pipeline error that confused you? Tell me in the comments.
Top comments (0)