Designing Job Execution Order
This lesson explains default order, dependencies, conditions, parallelism and multi-stage design.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the default order on each platform.
- Write fan-out and fan-in dependencies.
- Apply conditions to a job graph.
- Use matrix strategies.
Default order
Each platform has a default order that a design must take into account. In Azure Pipelines, stages run one after another in the order written, as each stage implicitly depends on the one before it. Jobs inside a stage run in parallel, subject to available agents. Steps inside a job always run in sequence.
In GitHub Actions, all jobs run in parallel unless needs says otherwise, and steps run in sequence. A workflow that needs an order must state it. This is the opposite of stages in Azure Pipelines, and it can catch out people moving between the two.
In sequence or in parallel by default?
Fan-out and fan-in
Dependencies describe a graph. The most common shape is fan-out and fan-in: one job leads to several parallel jobs, which then join into a final job.
# Azure Pipelines
stages:
- stage: Build
- stage: TestLinux
dependsOn: Build
- stage: TestWindows
dependsOn: Build
- stage: Deploy
dependsOn:
- TestLinux
- TestWindows
# GitHub Actions
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: ./build.sh
test-linux:
needs: build
runs-on: ubuntu-latest
steps:
- run: ./test.sh
test-windows:
needs: build
runs-on: windows-latest
steps:
- run: ./test.ps1
deploy:
needs: [test-linux, test-windows]
runs-on: ubuntu-latest
steps:
- run: ./deploy.shIn Azure Pipelines, dependsOn: [] removes the implicit dependency, so that a stage runs immediately, in parallel with the first. By default, a job or stage with a dependency runs only if all its dependencies succeed. To change this, add a condition.
The following diagram compares the jobs with and without needs.

Conditions on the graph
Conditions allow branches in the graph, such as a clean-up job after a failure. In Azure Pipelines, a custom condition replaces the default, so succeeded() must be included explicitly if it is still wanted. dependencies.Build.result tests the outcome of another job.
# Azure Pipelines: run a rollback job only if deployment failed
- job: Rollback
dependsOn: Deploy
condition: failed()
# Azure Pipelines: run clean-up whatever happened
- job: CleanUp
dependsOn: Test
condition: always()
# GitHub Actions equivalents
rollback:
needs: deploy
if: failure()
clean-up:
needs: test
if: always()If a job has been skipped, jobs depending on it are normally skipped too. In GitHub Actions, if: always() or a check on needs.job.result is needed for a job to run regardless. continue-on-error: true lets a job fail without failing the workflow, which suits experimental matrix entries. In Azure Pipelines, continueOnError: true produces a partially succeeded result.
Conditions and skipped jobs
Parallelism and matrices
Running work in parallel is the most direct way to shorten a pipeline, provided that there is capacity. A matrix creates one job for each combination of values, which avoids duplicating YAML.
# Azure Pipelines
jobs:
- job: Test
strategy:
maxParallel: 2
matrix:
node20:
nodeVersion: '20.x'
node22:
nodeVersion: '22.x'
steps:
- task: UseNode@1
inputs:
version: $(nodeVersion)
# GitHub Actions
jobs:
test:
strategy:
fail-fast: false
max-parallel: 2
matrix:
node: [20, 22]
os: [ubuntu-latest, windows-latest]
exclude:
- os: windows-latest
node: 20
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}The GitHub example produces three jobs: two operating systems by two versions, less the excluded combination. By default, fail-fast cancels the remaining jobs after one fails, which saves minutes but hides other failures, so setting it to false shows all results. A matrix can generate up to 256 jobs per workflow run.
Azure Pipelines also has a parallel strategy, which runs the same job on several agents, usually to slice a test suite across them. A pipeline's concurrency is ultimately limited by parallel jobs in Azure Pipelines, and by plan limits in GitHub, so a design with 20 parallel jobs and five licensed jobs simply queues.
Counting matrix jobs
Designing a multi-stage pipeline
A multi-stage pipeline usually mirrors the path to production. A sound design has a few properties. One build stage produces one artifact. Each later stage deploys that artifact to an environment with its own checks. Production stages depend on staging or test, and regions are deployed in sequence. Failure in any stage stops promotion.
Stages also have a practical benefit in Azure Pipelines: a failed stage can be retried without running the whole pipeline. GitHub offers re-running failed jobs. Both retries are safer if deployments are idempotent, so that repeating them causes no harm.
A sound multi-stage design
Reading a graph
A GitHub Actions workflow has jobs build, test and deploy with no needs keys. The deploy job often fails with a missing artifact. What is wrong?
All three jobs start at once, so deploy runs before build has uploaded the artifact. The fix is needs: build on test and needs: test on deploy, or needs: [build, test] on deploy. Stages do not exist in GitHub Actions. Adding a wait step would be a fragile workaround, and retrying the job would still not guarantee the order.
In Azure Pipelines, how do you make a stage run at the same time as the first stage?
Show answer
Set dependsOn: [] on it, which removes the implicit dependency on the previous stage.
Exam Tips
Remember for the exam
- Azure Pipelines stages run in sequence; GitHub Actions jobs run in parallel by default.
- A custom condition replaces succeeded(), so include it if required.
- Use dependsOn: [] to run a stage in parallel with the first.
- fail-fast: false lets all matrix jobs finish.
- Parallelism is limited by parallel jobs or plan limits.