@@ -96,7 +96,8 @@ function GenerateMatrix(
9696 [String ]$displayNameFilter = " .*" ,
9797 [Array ]$filters = @ (),
9898 [Array ]$replace = @ (),
99- [Array ]$nonSparseParameters = @ ()
99+ [Array ]$nonSparseParameters = @ (),
100+ [Switch ]$skipEnvironmentVariables
100101) {
101102 $matrixParameters , $importedMatrix , $combinedDisplayNameLookup = `
102103 ProcessImport $config.matrixParameters $selectFromMatrixType $nonSparseParameters $config.displayNamesLookup
@@ -124,7 +125,9 @@ function GenerateMatrix(
124125
125126 $matrix = FilterMatrix $matrix $filters
126127 $matrix = ProcessReplace $matrix $replace $combinedDisplayNameLookup
127- $matrix = ProcessEnvironmentVariableReferences $matrix $combinedDisplayNameLookup
128+ if (! $skipEnvironmentVariables ) {
129+ $matrix = ProcessEnvironmentVariableReferences $matrix $combinedDisplayNameLookup
130+ }
128131 $matrix = FilterMatrixDisplayName $matrix $displayNameFilter
129132 return $matrix
130133}
@@ -427,10 +430,14 @@ function ProcessImport([MatrixParameter[]]$matrix, [String]$selection, [Array]$n
427430 exit 1
428431 }
429432 $importedMatrixConfig = GetMatrixConfigFromFile (Get-Content - Raw $importPath )
433+ # Add skipEnvironmentVariables so we don't process environment variables on import
434+ # because we want top level filters to work against the the env key, not the value.
435+ # The environment variables will get resolved after the import.
430436 $importedMatrix = GenerateMatrix `
431437 - config $importedMatrixConfig `
432438 - selectFromMatrixType $selection `
433- - nonSparseParameters $nonSparseParameters
439+ - nonSparseParameters $nonSparseParameters `
440+ - skipEnvironmentVariables
434441
435442 $combinedDisplayNameLookup = $importedMatrixConfig.displayNamesLookup
436443 foreach ($lookup in $displayNamesLookup.GetEnumerator ()) {
0 commit comments