diff --git a/eng/common/scripts/job-matrix/job-matrix-functions.ps1 b/eng/common/scripts/job-matrix/job-matrix-functions.ps1 index 198d68f00f7f..f20dbe5281b0 100644 --- a/eng/common/scripts/job-matrix/job-matrix-functions.ps1 +++ b/eng/common/scripts/job-matrix/job-matrix-functions.ps1 @@ -96,7 +96,8 @@ function GenerateMatrix( [String]$displayNameFilter = ".*", [Array]$filters = @(), [Array]$replace = @(), - [Array]$nonSparseParameters = @() + [Array]$nonSparseParameters = @(), + [Switch]$skipEnvironmentVariables ) { $matrixParameters, $importedMatrix, $combinedDisplayNameLookup = ` ProcessImport $config.matrixParameters $selectFromMatrixType $nonSparseParameters $config.displayNamesLookup @@ -124,7 +125,9 @@ function GenerateMatrix( $matrix = FilterMatrix $matrix $filters $matrix = ProcessReplace $matrix $replace $combinedDisplayNameLookup - $matrix = ProcessEnvironmentVariableReferences $matrix $combinedDisplayNameLookup + if (!$skipEnvironmentVariables) { + $matrix = ProcessEnvironmentVariableReferences $matrix $combinedDisplayNameLookup + } $matrix = FilterMatrixDisplayName $matrix $displayNameFilter return $matrix } @@ -427,10 +430,14 @@ function ProcessImport([MatrixParameter[]]$matrix, [String]$selection, [Array]$n exit 1 } $importedMatrixConfig = GetMatrixConfigFromFile (Get-Content -Raw $importPath) + # Add skipEnvironmentVariables so we don't process environment variables on import + # because we want top level filters to work against the the env key, not the value. + # The environment variables will get resolved after the import. $importedMatrix = GenerateMatrix ` -config $importedMatrixConfig ` -selectFromMatrixType $selection ` - -nonSparseParameters $nonSparseParameters + -nonSparseParameters $nonSparseParameters ` + -skipEnvironmentVariables $combinedDisplayNameLookup = $importedMatrixConfig.displayNamesLookup foreach ($lookup in $displayNamesLookup.GetEnumerator()) {