How to Define Stages and Jobs in Azure Pipelines
An Azure Pipeline nests stages > jobs > steps. Stages group work, jobs run on an agent, and steps are the commands.
A stage is a logical phase (build, test, deploy). Each job inside a stage runs on its own agent in parallel by default; dependsOn enforces order.
The three levels
Stages run sequentially when chained with dependsOn; jobs in a stage run in parallel unless they declare dependencies.
azure-pipelines.yml
stages:
- stage: Build
jobs:
- job: Compile
pool:
vmImage: ubuntu-latest
steps:
- script: npm ci && npm run build
- stage: Test
dependsOn: Build
jobs:
- job: Unit
steps:
- script: npm testGotchas
- Each job gets a fresh agent and workspace - files do not carry over unless you publish/download pipeline artifacts.
- Without
dependsOn, stages still run in listed order, but jobs within a stage fan out in parallel. - A single-stage pipeline can omit the
stages:key and listjobs:directly.
Related guides
How to Create a Multi-Stage Pipeline in Azure PipelinesBuild a build-test-deploy multi-stage pipeline in Azure Pipelines with dependsOn chaining and condition so de…
How to Set Output Variables Between Jobs in Azure PipelinesPass a value from one Azure Pipelines job to another with an isOutput logging command and dependencies.<job>.…