1. A continuous integration pipeline #
azure-pipelines.yml.
The file #
trigger:
branches:
include: [main]
pr:
branches:
include: [main]
pool:
name: Default # self-hosted agent; or vmImage: ubuntu-latest
steps:
- script: |
python3 -m venv .venv
.venv/bin/pip install -r requirements-dev.txt
.venv/bin/pytest --junitxml=$(Build.ArtifactStagingDirectory)/rapport.xml
displayName: Tests
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: $(Build.ArtifactStagingDirectory)/rapport.xml
testRunTitle: Shop tests
- task: PublishPipelineArtifact@1
inputs:
targetPath: $(Build.SourcesDirectory)
artifact: boutique- Tasks (
PublishTestResults@2) are ready-made actions, versioned by their major number. - Predefined variables (
$(Build.BuildId),$(Build.SourceBranchName),$(Build.ArtifactStagingDirectory)) describe the run.
2. Variables, expressions and templates #
Parameterize and factor.
Three syntaxes #
| Syntax | Evaluated | Use |
|---|---|---|
| ${{ variables.x }} | when the YAML is compiled | parameters, structural conditions, templates |
| $[ variables.x ] | at runtime, before the job | conditions and computed variables |
| $(x) | at runtime, in the task | values in scripts and task inputs |
# templates/deploy.yml
parameters:
- name: environment
type: string
- name: port
type: number
jobs:
- deployment: deploy_${{ parameters.environment }}
environment: ${{ parameters.environment }}
strategy:
runOnce:
deploy:
steps:
- script: ./deploy.sh ${{ parameters.environment }} ${{ parameters.port }}
# azure-pipelines.yml
variables:
- group: shop-common # variable group (Library)
stages:
- stage: Staging
jobs:
- template: templates/deploy.yml
parameters: { environment: staging, port: 8081 }- Variable groups (Pipelines › Library) share values across pipelines, optionally linked to Azure Key Vault.
extendsenforces an approved pipeline template: a "required template" check rejects pipelines that do not use it.
Watch out : A secret variable is never passed automatically to scripts: pass it explicitly through env:.Commands to know #
Commands to know
az pipelines create --name boutique-ci --yml-path azure-pipelines.yml: create a pipelineaz pipelines run --name boutique-ci: run a pipelineaz pipelines variable-group create --name boutique-commun --variables REGISTRE=…: create a variable groupaz pipelines runs list --top 5 -o table: latest runs
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
Deploying with Azure Pipelines: environments, approvals and service connections
Delivering with Azure Pipelines: multi-stage pipelines, environments, approvals and checks, deplo...
Azure Pipelines agents: hosted, self-hosted and managed pools
Choosing and running Azure Pipelines agents: Microsoft-hosted agents and images, self-hosted agen...
Azure DevOps: services, organization and plans
Discover Azure DevOps: Boards, Repos, Pipelines, Test Plans and Artifacts, organizations and proj...
Reusing and securing GitLab pipelines
Industrializing GitLab CI/CD: extends, anchors and !reference, include, CI/CD components and cata...
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 ...
Azure DevOps security, governance and best practices
Running Azure DevOps securely: permissions and groups, protected resources, pipeline authorizatio...
Azure Boards and Azure Repos: planning and collaborating
Organizing work with Azure Boards (Agile, Scrum, Basic and CMMI processes, work items, backlogs, ...
GitLab CI/CD: concepts and architecture
Discover GitLab CI/CD: the DevSecOps platform, the .gitlab-ci.yml file, pipelines, stages and job...
Writing GitHub Actions workflows
Mastering workflow syntax: triggers and filters, jobs and needs, matrices, if conditions, context...