azure-sdk-for-cpp/eng/common/scripts/job-matrix/Create-JobMatrix.ps1
Azure SDK Bot 5a1fedd0d5
Sync eng/common directory with azure-sdk-tools for PR 1429 (#1705)
* Add job matrix generation scripts

* Add working job matrix example pipeline and common matrix generation pipeline.

* Update job matrix tests path

* Parameterize matrix generation job path

* Add global variable to override nuget security checks to sample matrix pipeline

* Update readme matrix pipeline example to match sample file

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
2021-02-19 14:45:31 -08:00

36 lines
1.2 KiB
PowerShell

<#
.SYNOPSIS
Generates a JSON object representing an Azure Pipelines Job Matrix.
See https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml#parallelexec
.EXAMPLE
./eng/common/scripts/Create-JobMatrix $context
#>
[CmdletBinding()]
param (
[Parameter(Mandatory=$True)][string] $ConfigPath,
[Parameter(Mandatory=$True)][string] $Selection,
[Parameter(Mandatory=$False)][string] $DisplayNameFilter,
[Parameter(Mandatory=$False)][array] $Filters,
[Parameter(Mandatory=$False)][array] $NonSparseParameters
)
. $PSScriptRoot/job-matrix-functions.ps1
$config = GetMatrixConfigFromJson (Get-Content $ConfigPath)
# Strip empty string filters in order to be able to use azure pipelines yaml join()
$Filters = $Filters | Where-Object { $_ }
[array]$matrix = GenerateMatrix `
-config $config `
-selectFromMatrixType $Selection `
-displayNameFilter $DisplayNameFilter `
-filters $Filters `
-nonSparseParameters $NonSparseParameters
$serialized = SerializePipelineMatrix $matrix
Write-Output $serialized.pretty
Write-Output "##vso[task.setVariable variable=matrix;isOutput=true]$($serialized.compressed)"