Skip to content
Latchkey

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 test

Gotchas

  • 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 list jobs: directly.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →