@@ -116,20 +116,41 @@ stages:
116
116
clean : true
117
117
118
118
- pwsh : |
119
+ # For PRs set the seed to the PR number so that the image is always the same
120
+ $seed = $env:SYSTEM_PULLREQUEST_PULLREQUESTID
121
+ if(!$seed) {
122
+ # for non-PRs use the integer identifier of the build as the seed.
123
+ $seed = $env:SYSTEM_BUILD_BUILDID
124
+ }
125
+ Write-Verbose "Seed: $seed" -Verbose
126
+
127
+ # Get the latest image matrix JSON for preview
119
128
$matrix = ./PowerShell-Docker/build.ps1 -GenerateMatrixJson -FullJson -Channel preview | ConvertFrom-Json
129
+
120
130
# Filter out containers that won't run on AzDevOps Linux host as an agent
121
131
# Windows, nano server, alpine, and any ARM image
122
132
$linuxImages = $matrix.preview |
123
133
Where-Object {$_.osversion -notmatch 'windows|nano|alpine|arm'} |
124
134
Select-Object JobName, Taglist |
125
135
Sort-Object -property JobName
126
- # Force mariner for now, later we will add automated rotation by the month.
136
+
137
+ # Force mariner for now
127
138
$marinerImage = $linuxImages | where-object {$_.JobName -like 'mariner*'}
128
- Import-Module ./PowerShell/tools/ci.psm1
129
- $tag = $marinerImage.Taglist -split ';' | select-object -first 1
139
+
140
+ # Use the selected seed to pick a container
141
+ $index = Get-Random -Minimum 0 -Maximum $marinerImage.Count -SetSeed $seed
142
+ $selectedImage = $marinerImage[$index]
143
+
144
+ # Filter to the first test-deps compatible tag
145
+ $tag = $selectedImage.Taglist -split ';' | Where-Object {$_ -match 'preview-\D+'} | Select-Object -First 1
146
+
147
+ # Calculate the container name
130
148
$containerName = "mcr.microsoft.com/powershell/test-deps:$tag"
149
+
150
+ # Set variables for later jobs to use
151
+ Import-Module ./PowerShell/tools/ci.psm1
131
152
Set-BuildVariable -Name containerName -Value $containerName -IsOutput
132
- Set-BuildVariable -Name containerBuildName -Value $marinerImage .JobName -IsOutput
153
+ Set-BuildVariable -Name containerBuildName -Value $selectedImage .JobName -IsOutput
133
154
name: getContainerTask
134
155
displayName: Get Container
135
156
continueOnError: true
0 commit comments