@@ -90,31 +90,33 @@ foreach ($matrixBatchKey in $matrixBatchesByConfig.Keys) {
90
90
91
91
$packageBatches = Split-ArrayIntoBatches - InputArray $matrixBatch - BatchSize $BATCHSIZE
92
92
93
- # we only need to modify the generated job name if there is more than one matrix config or batch in the matrix
94
- $matrixSuffixNecessary = $matrixConfigs .Count -gt 1
93
+ # we only need to modify the generated job name if there is more than one matrix config + batch
94
+ $matrixSuffixNecessary = $matrixBatchesByConfig .Keys .Count -gt 1
95
95
$batchSuffixNecessary = $packageBatches.Length -gt 1
96
96
$batchCounter = 1
97
97
98
98
foreach ($batch in $packageBatches ) {
99
+ $namesForBatch = ($batch | ForEach-Object { $_.ArtifactName }) -join " ,"
99
100
# to understand this iteration, one must understand that the matrix is a list of hashtables, each with a couple keys:
100
101
# [
101
102
# { "name": "jobname", "parameters": { matrixSetting1: matrixValue1, ...} },
102
103
# ]
103
104
foreach ($matrixOutputItem in $matrixResults ) {
104
- $namesForBatch = ($batch | ForEach-Object { $_.ArtifactName }) -join " ,"
105
+ # we need to clone this, as each item is an object with possible children
106
+ $outputItem = $matrixOutputItem | ConvertTo-Json - Depth 100 | ConvertFrom-Json - AsHashtable
105
107
# we just need to iterate across them, grab the parameters hashtable, and add the new key
106
108
# if there is more than one batch, we will need to add a suffix including the batch name to the job name
107
- $matrixOutputItem [" parameters" ][" $PRMatrixSetting " ] = $namesForBatch
109
+ $outputItem [" parameters" ][" $PRMatrixSetting " ] = $namesForBatch
108
110
109
111
if ($matrixSuffixNecessary ) {
110
- $matrixOutputItem [" name" ] = $matrixOutputItem [" name" ] + $matrixConfig.Name
112
+ $outputItem [" name" ] = $outputItem [" name" ] + " _ " + $matrixConfig.Name
111
113
}
112
114
113
115
if ($batchSuffixNecessary ) {
114
- $matrixOutputItem [" name" ] = $matrixOutputItem [" name" ] + " b $batchCounter "
116
+ $outputItem [" name" ] = $outputItem [" name" ] + " _b $batchCounter "
115
117
}
116
118
117
- $OverallResult += $matrixOutputItem
119
+ $OverallResult += $outputItem
118
120
}
119
121
$batchCounter += 1
120
122
}
0 commit comments