Skip to content

Instantly share code, notes, and snippets.

@bravo-kernel
Last active April 26, 2024 12:35
Show Gist options
  • Save bravo-kernel/2d7357175e3e8d783318a73f6329df1e to your computer and use it in GitHub Desktop.
Save bravo-kernel/2d7357175e3e8d783318a73f6329df1e to your computer and use it in GitHub Desktop.
Multi-stage Azure Devops Pipeline with cross-platform matrix
# Determines which branch(es) will cause a CI build to be started
trigger:
- master
# Stages precede strategy, in other words each stage can contain a strategy (or multiple or none)
# Full run-cylce described here: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/runs?view=azure-devops
stages:
- stage: Prepare
jobs:
- job:
pool:
vmImage: 'ubuntu-16.04'
steps:
- powershell: |
"OS = $($env:AGENT_OS)" | Out-Host
displayName: 'Dummy Prepare Step'
- stage: Build
dependsOn: Prepare
jobs:
- job:
pool:
vmImage: 'windows-2019'
steps:
- powershell: |
"OS = $($env:AGENT_OS)" | Out-Host
displayName: 'Dummy Build Step'
- stage: Test
dependsOn: Build
jobs:
- job:
strategy:
matrix:
Linux:
imageName: 'ubuntu-16.04'
Mac:
imageName: 'macOS-10.14'
Windows:
imageName: 'windows-2019'
Code Coverage:
imageName: 'windows-2019'
Script Analysis:
imageName: 'windows-2019'
pool:
vmImage: $(imageName)
steps:
- powershell: |
"OS = $($env:AGENT_OS)" | Out-Host
displayName: 'Dummy Test Step'
- stage: Document
dependsOn: Test
jobs:
- job:
pool:
vmImage: 'windows-2019'
steps:
- powershell: |
"OS = $($env:AGENT_OS)" | Out-Host
displayName: 'Dummy Document Step'
- stage: Release
dependsOn: Document
jobs:
- job:
pool:
vmImage: 'windows-2019'
steps:
- powershell: |
"OS = $($env:AGENT_OS)" | Out-Host
displayName: 'Dummy Release Step'
@bravo-kernel
Copy link
Author

bravo-kernel commented Jun 8, 2019

This Azure Devops Pipeline creates 5 stages where the cross-platform matrix in the Test stage will generate 5 separate jobs for that stage, one for each platform.

Please note that you MUST enable the preview feature Multi-stage pipelines in your Azure Devops user profile for this to work.

It will look like this when running the pipeline:

image

When the run has completed it will look like this:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment