1. Reusing #
No more copy-paste.
The levels #
# templates/python-test/template.yml (CI/CD component)
spec:
inputs:
python_version:
default: "3.12"
stage:
default: test
---
python-test:
stage: $[[ inputs.stage ]]
image: python:$[[ inputs.python_version ]]-slim
script: [pip install -r requirements-dev.txt, pytest]
# .gitlab-ci.yml of a consuming project
include:
- component: $CI_SERVER_FQDN/mon-groupe/ci-components/python-test@1.2.0
inputs: { python_version: "3.13" }
- template: Jobs/SAST.gitlab-ci.yml
- template: Jobs/Secret-Detection.gitlab-ci.ymlextendsinherits from a hidden job (.python);!referencereuses a precise part (ascriptlist).- CI/CD components are versioned (semantic tags), parameterized by
spec:inputsand published to the CI/CD catalog; pin a precise version. - Parent-child pipelines (
trigger: include) split a monorepo; multi-project pipelines (trigger: project) chain several repositories.
2. Secrets and identities #
No long-lived key in CI.
OIDC #
deploy:
id_tokens:
CLOUD_TOKEN:
aud: https://iam.example-cloud.com
script:
- ./exchange-token.sh "$CLOUD_TOKEN" # the provider checks project, branch and environmentid_tokens generates an OIDC token signed by GitLab for this job; AWS, Azure, Google Cloud or Vault exchange it for temporary rights, limited to a project, branch or environment. The old CI_JOB_JWT is removed.
Watch out : A masked variable is not a vault: a job can write it to a file or encode it. Restrict sensitive variables to protected branches.
3. Built-in security and merge requests #
Controls in the right place.
Scans #
| Template | Detects | Plan |
|---|---|---|
| Jobs/SAST | code vulnerabilities | Free |
| Jobs/Secret-Detection | committed secrets | Free |
| Jobs/Dependency-Scanning | vulnerable dependencies | Ultimate |
| Jobs/Container-Scanning | image vulnerabilities | Free (rapport) / Ultimate (tableaux) |
- Merge request pipelines test the branch; merged results pipelines test the result of merging with the target.
- Merge trains (Premium) queue merges, testing each on top of the previous ones: the main branch stays green.
Commands to know #
Commands to know
glab ci lint: validate includes and componentsglab variable set NOM --masked --protected: create a protected variableglab mr create --fill: open a merge request
Sources #
Checked in November 2026: CI/CD platforms change every month, check versions and plans in the vendor's documentation.
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
Reusing and securing GitHub Actions workflows
Industrializing GitHub Actions: reusable workflows, composite, JavaScript and Docker actions, lea...
DevSecOps: securing the software supply chain end to end
Integrate security into the DevOps pipeline: shift-left, threat modeling, secret detection, SAST,...
GitLab CI/CD best practices and troubleshooting
Running GitLab CI/CD day to day: speeding up pipelines, controlling compute minutes, organizing f...
Terraform in CI/CD: pipelines, plan review, OIDC and GitOps
Automate Terraform: plan pipeline on merge requests and apply after approval, posting the plan as...
GitLab runners: types, executors, installation and security
Running GitLab jobs: instance, group and project runners, docker, kubernetes and docker-autoscale...
GitLab CI/CD: concepts and architecture
Discover GitLab CI/CD: the DevSecOps platform, the .gitlab-ci.yml file, pipelines, stages and job...
Writing a .gitlab-ci.yml: jobs, rules, cache and artifacts
Mastering .gitlab-ci.yml syntax: stages, jobs and images, rules and workflow, needs (DAG), cache ...
Building and delivering with GitLab: registry, environments and deployments
Delivering with GitLab CI/CD: building and publishing images to the project registry, package reg...
Azure YAML pipelines: stages, tasks, variables and templates
Writing Azure pipelines in YAML: trigger and pr triggers, stages, jobs and steps, versioned tasks...