Learn GitLab CI/CD

GitLab's built-in pipelines: build, test and deploy from .gitlab-ci.yml

14 lessons · 3 hours · 4 levels · covers GitLab CI/CD 19

GitLab CI/CD runs pipelines defined in a .gitlab-ci.yml file at the root of a GitLab repository. Jobs are grouped into stages, executed by runners (usually inside Docker images), and can pass artifacts, deploy to environments and trigger other pipelines. It is the standard way to automate builds, tests and deployments for teams that host their code on GitLab.com or a self-managed GitLab.

Before you start

GitLab CI/CD builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics4 lessons · 34 min in total
2. PracticalUse it productively at work, with the usual idioms8 lessons · 1 hour in total
3. AdvancedThe less common features, performance and trade-offs11 lessons · 2 hours in total
4. ExpertInternals and the edge cases experts know14 lessons · 3 hours in total

The GitLab CI/CD tree

GitLab CI/CDPipelines, stages, jobs and runnersPipelines, stages,jobs and runnersYour first .gitlab-ci.ymlYour first.gitlab-ci.ymlImages, services and default settingsImages, services anddefault settingsCI/CD variables and predefined variablesCI/CD variables andpredefined variablesControlling when jobs run with rulesControlling when jobsrun with rulesArtifacts and cacheArtifacts and cacheneeds: faster pipelines as a DAGneeds: fasterpipelines as a DAGSecrets: masked, protected and file variablesSecrets: masked,protected and file v…Sharing work: push and pullSharing work: pushand pullImages and containersImages andcontainers
Essentials and Practical shown (8 of 14 lessons); the full list is below. Click a lesson to read it.

All 14 lessons, in order

Pipeline basics

  1. Pipelines, stages, jobs and runners · Essentials · 6 min

    The building blocks of GitLab CI/CD: a pipeline of stages, each holding jobs, executed by runners.

  2. Your first .gitlab-ci.yml · Essentials · 10 min

    Write a pipeline that installs dependencies and runs tests in a Docker image, then watch it run after a push.

  3. Images, services and default settings · Essentials · 10 min

    Pick a Docker image per job, start helper containers like databases with services, and share settings with default.

  4. CI/CD variables and predefined variables · Essentials · 8 min

    Define variables in YAML, use GitLab's predefined CI_ variables, and know the precedence when the same name is set twice.

Rules, artifacts and DAGs

  1. Controlling when jobs run with rules · Practical · 12 min

    Use rules with if, changes and exists to add jobs conditionally, make them manual, and control whole pipelines with workflow:rules.

  2. Artifacts and cache · Practical · 12 min

    Pass build output to later jobs with artifacts, publish test reports, and speed up installs with cache keyed on lockfiles.

  3. needs: faster pipelines as a DAG · Practical · 10 min

    Let jobs start as soon as the jobs they depend on finish, ignoring stage order, and control which artifacts they fetch.

Variables and secrets

  1. Secrets: masked, protected and file variables · Practical · 10 min

    Store credentials as project or group CI/CD variables, mask them in logs, and restrict them to protected branches.

Reuse and deployment

  1. include, extends, !reference and components · Advanced · 14 min

    Split configuration into files, share templates across projects, inherit job settings with extends, and use CI/CD components.

  2. Environments, manual deploys and review apps · Advanced · 12 min

    Track deployments with environment:, gate production with manual jobs and protected environments, and spin up review apps per merge request.

  3. Parent-child and multi-project pipelines · Advanced · 12 min

    Split big pipelines into child pipelines, generate configuration dynamically, and trigger pipelines in other projects.

Runners and pipelines at scale

  1. Runners and executors · Expert · 14 min

    Install and register GitLab Runner, choose an executor, route jobs with tags and tune concurrency and autoscaling.

  2. ID tokens, OIDC and pipeline security · Expert · 14 min

    Authenticate to clouds and Vault with id_tokens instead of stored keys, and close the common holes in pipeline security.

  3. Merge request pipelines and merge trains · Expert · 14 min

    Understand branch vs merge request vs merged results pipelines, and how merge trains keep main green under heavy merge traffic.