Skip to content

Commit ba0077a

Browse files
nohwndCopilot
andauthored
Fix VS insertion app.config push: drop spurious regex prefix and disambiguate build number (#15790)
The post-roslyn-tools step that pushes vstest.console/app.config and revision.txt into the VS insertion PR has been silently failing on every run since it landed. Two compounding bugs in the source-commit resolution: 1. The primary regex matched 'Updated Updating VS Test Platform from' but roslyn-tools logs 'Updating VS Test Platform from' (no 'Updated' prefix). The primary path never fired, so the fallback always ran. 2. The fallback queried '/builds?buildNumber=20260514.9' and took value[0]. buildNumber is not unique across pipelines — on a typical day it matches builds from dotnet-roslyn, dotnet-runtime, microsoft-vstest, microsoft-testfx, dotnet-wpf, and several others. The fallback returned the first one (e.g. dotnet-roslyn), then tried to fetch app.config from the microsoft-vstest mirror at that unrelated SHA, failing with TF401029: GitCommitDoesNotExistException. Drop the bogus 'Updated ' prefix from the primary regex (verified against the actual log line in build 2975466) and filter the fallback result by definition.name so the right pipeline is picked. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0069e8d commit ba0077a

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

azure-pipelines-insertion.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ extends:
221221
222222
$sourceCommit = $null
223223
224-
# Extract the build ID from the "Updated Updating VS Test Platform from [...] to [buildnum](url) ([sha](sourcesUrl))" line.
224+
# Extract the build ID from the "Updating VS Test Platform from [...] to [buildnum](url) ([sha](sourcesUrl))" line.
225225
# We use the build ID to resolve the full commit SHA via the builds API.
226-
if ($outputText -match 'Updated Updating VS Test Platform from .+ to \[\S+\]\([^)]+\) \(\[[0-9a-f]{7,40}\]\(https://dev\.azure\.com/dnceng/[^)]+/_apis/build/builds/(\d+)/sources\)\)') {
226+
if ($outputText -match 'Updating VS Test Platform from .+ to \[\S+\]\([^)]+\) \(\[[0-9a-f]{7,40}\]\(https://dev\.azure\.com/dnceng/[^)]+/_apis/build/builds/(\d+)/sources\)\)') {
227227
$sourceBuildId = $Matches[1]
228228
Write-Host "Resolving source commit from build ID $sourceBuildId"
229229
$buildUrl = "$dncengBase/_apis/build/builds/${sourceBuildId}?api-version=7.1"
@@ -232,14 +232,17 @@ extends:
232232
}
233233
234234
if (-not $sourceCommit) {
235-
# Fallback: resolve source commit from build number via AzDO API
235+
# Fallback: resolve source commit from build number via AzDO API.
236+
# buildNumber is not unique across pipelines (e.g. "20260514.9" matches dotnet-roslyn,
237+
# dotnet-runtime, microsoft-vstest, ...) so filter the result by the mirror pipeline name.
236238
if ($outputText -match 'Found microsoft-vstest build number (\S+)') {
237239
$buildNumber = $Matches[1]
238240
Write-Host "Resolving source commit from build number $buildNumber"
239241
$buildsUrl = "$dncengBase/_apis/build/builds?buildNumber=$buildNumber&api-version=7.1"
240242
$buildsResponse = Invoke-RestMethod -Uri $buildsUrl -Headers $dncengHeaders -Method Get
241-
if ($buildsResponse.value -and $buildsResponse.value.Count -gt 0) {
242-
$sourceCommit = $buildsResponse.value[0].sourceVersion
243+
$matchingBuild = $buildsResponse.value | Where-Object { $_.definition.name -eq $mirrorRepoId } | Select-Object -First 1
244+
if ($matchingBuild) {
245+
$sourceCommit = $matchingBuild.sourceVersion
243246
}
244247
}
245248
}

0 commit comments

Comments
 (0)