Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve type and null handling
  • Loading branch information
benbp authored and azure-sdk committed Feb 15, 2024
commit f75bc10b04a6f45fddc3eb3722e276561ba4ee54
10 changes: 8 additions & 2 deletions eng/common/scripts/job-matrix/job-matrix-functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MatrixParameter {
$displayName = $this.Value.ToString()
}

if ($displayNamesLookup.ContainsKey($displayName)) {
if ($displayNamesLookup -and $displayNamesLookup.ContainsKey($displayName)) {
$displayName = $displayNamesLookup[$displayName]
}

Expand Down Expand Up @@ -339,6 +339,9 @@ function ProcessReplace {

foreach ($element in $matrix) {
$replacement = [MatrixParameter[]]@()
if (!$element -or $element.Count -eq 0) {
continue
}

foreach ($perm in $element._permutation) {
$replace = $perm
Expand Down Expand Up @@ -372,11 +375,14 @@ function ProcessEnvironmentVariableReferences([array]$matrix, $displayNamesLooku

foreach ($element in $matrix) {
$updated = [MatrixParameter[]]@()
if (!$element -or $element.Count -eq 0) {
continue
}

foreach ($perm in $element._permutation) {
# Iterate nested permutations or run once for singular values (int, string, bool)
foreach ($flattened in $perm.Flatten()) {
if ($flattened.Value?.GetType() -eq "".GetType() -and $flattened.Value.StartsWith("env:")) {
if ($flattened.Value -is [string] -and $flattened.Value.StartsWith("env:")) {
$envKey = $flattened.Value.Replace("env:", "")
$value = [System.Environment]::GetEnvironmentVariable($envKey) ?? ""
if (!$value) {
Expand Down