@@ -90,31 +90,33 @@ foreach ($matrixBatchKey in $matrixBatchesByConfig.Keys) {
9090
9191 $packageBatches = Split-ArrayIntoBatches - InputArray $matrixBatch - BatchSize $BATCHSIZE
9292
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
9595 $batchSuffixNecessary = $packageBatches.Length -gt 1
9696 $batchCounter = 1
9797
9898 foreach ($batch in $packageBatches ) {
99+ $namesForBatch = ($batch | ForEach-Object { $_.ArtifactName }) -join " ,"
99100 # to understand this iteration, one must understand that the matrix is a list of hashtables, each with a couple keys:
100101 # [
101102 # { "name": "jobname", "parameters": { matrixSetting1: matrixValue1, ...} },
102103 # ]
103104 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
105107 # we just need to iterate across them, grab the parameters hashtable, and add the new key
106108 # 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
108110
109111 if ($matrixSuffixNecessary ) {
110- $matrixOutputItem [" name" ] = $matrixOutputItem [" name" ] + $matrixConfig.Name
112+ $outputItem [" name" ] = $outputItem [" name" ] + " _ " + $matrixConfig.Name
111113 }
112114
113115 if ($batchSuffixNecessary ) {
114- $matrixOutputItem [" name" ] = $matrixOutputItem [" name" ] + " b $batchCounter "
116+ $outputItem [" name" ] = $outputItem [" name" ] + " _b $batchCounter "
115117 }
116118
117- $OverallResult += $matrixOutputItem
119+ $OverallResult += $outputItem
118120 }
119121 $batchCounter += 1
120122 }
0 commit comments