The issue opens pre-filled with this page title and URL.
GitLab CI/CD automates the repetitive tasks of your project: compiling the code, running the tests, checking quality, deploying the application. You describe these tasks in a configuration file, .gitlab-ci.yml, and GitLab does the rest on every git push.
What you will learn
By the end of this module, you will be able to:
Understand what GitLab CI/CD is: the automation tool built into GitLab
Know the 4 key concepts: pipeline, stage, job, runner
Identify the .gitlab-ci.yml file: where to put it, what it contains
View a pipeline: navigate the GitLab interface
Read the logs of a job: understand what happened
What is GitLab CI/CD?
CI stands for Continuous Integration: on every commit, the code is automatically built and tested. If something breaks, you know immediately.
CD stands for Continuous Delivery/Deployment: validated code is automatically prepared (or deployed) to an environment.
GitLab CI/CD is built directly into GitLab. No need to install Jenkins, CircleCI or any other external tool. Everything is configured in your repository.
Why use it?
Picture your current workflow without CI/CD:
You code a feature
You run the tests... manually (or you forget)
You send the code to the server... via FTP or SSH
A bug in production? You don't know which commit introduced it
The pipeline contains 3 stages that chain from left to right
The "test" stage contains 2 jobs (test + lint) that run in parallel
If the "build" stage fails, the "test" and "deploy" stages do not run
The runners run each job in an isolated environment
What does the .gitlab-ci.yml file look like?
All the configuration lives in a file named .gitlab-ci.yml placed at the root of your Git repository.
A minimal example
# Define the stages (in order)
stages:
- build
- test
# First job: compile
build:
stage: build
script:
- echo "Compiling the code..."
- echo "Done!"
# Second job: test
test:
stage: test
script:
- echo "Running the tests..."
- echo "All tests pass!"
Explanations:
stages: defines the order of the steps
Each job has a name (build, test)
stage: tells which step the job belongs to
script: holds the commands to run
What does a complete job look like?
my-job:
stage: test# Stage the job belongs to
image: node:24-alpine@sha256:a0b9bf06e4e6193cf7a0f58816cc935ff8c2a908f81e6f1a95432d679c54fbfd# Docker image used (environment)
before_script: # Commands BEFORE the main script
- npm install
script: # Main commands (REQUIRED)
- npm test
after_script: # Commands AFTER (even on failure)
- echo "Cleaning up..."
artifacts: # Files to keep after the job
paths:
- coverage/
Only script: is required. Everything else is optional.
Which predefined variables are useful?
GitLab makes variables available in every job. The most common ones:
Variable
Description
Example
CI_COMMIT_BRANCH
Branch name
main, feature/login
CI_COMMIT_SHORT_SHA
Short commit hash
a1b2c3d4
CI_PROJECT_NAME
Project name
my-app
CI_PIPELINE_SOURCE
What triggered the pipeline
push, merge_request_event
Swipe to see more
build:
script:
- echo "Building commit $CI_COMMIT_SHORT_SHA on branch $CI_COMMIT_BRANCH"
How do you view your pipelines?
In GitLab, click Build > Pipelines in the sidebar to see:
The list of all your pipelines
The visual graph of stages and jobs
The status of each job (green/red/orange)
The detailed logs of each job
The graph shows the stages (columns) and the jobs (boxes). Here, the build stage finished successfully (green), then the test stage is running. The jobs of a same stage run in parallel.
Click a job to see its logs in real time while it runs:
The logs show every command that ran and its output. Notice the CI variables ($CI_COMMIT_BRANCH, $CI_COMMIT_SHORT_SHA) resolved to their actual values.
Key takeaways
Concept
Definition
Pipeline
Complete workflow triggered by an event
Stage
Step of the pipeline (run in order)
Job
Unit task with commands (parallel within a stage)
Runner
Machine that runs the jobs
.gitlab-ci.yml
Configuration file at the root
Swipe to see more
Knowledge check
Test your knowledge of the fundamentals of GitLab CI/CD pipelines.
Knowledge check
Check what you have learned with this interactive quiz
10 questions
5 min
70% to pass
How it works
The timer starts when you click Start
Multiple choice, true/false and short answer questions
You can move between questions
Detailed results are shown at the end
Starts the quiz and the timer
⏱️--:--
0 / 10
Review
(0/0)
--:--
0%
0Correct
0To review
0:00Time
-Level
Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.