fix(artifacts): Retry WinRM connect in Get-BuildArtifacts (wsmprovhost delay)

After Invoke-RemoteBuild closes its session, wsmprovhost.exe may take a moment
to release resources. Subsequent New-PSSession in Get-BuildArtifacts fails with
'WSMan service could not launch a host process'.

Add retry loop: 3 attempts, 10s backoff. Enough for WinRM to recover between
the build session and artifact collection session.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Simone
2026-05-10 22:23:11 +02:00
parent 73bb9b182b
commit d1f267b67c
+20 -8
View File
@@ -68,14 +68,26 @@ if (-not (Test-Path $HostArtifactDir)) {
$sessionOptions = New-CISessionOption $sessionOptions = New-CISessionOption
Write-Host "[Get-BuildArtifacts] Connecting to VM at $IPAddress..." Write-Host "[Get-BuildArtifacts] Connecting to VM at $IPAddress..."
$session = New-PSSession ` $session = $null
-ComputerName $IPAddress ` $attempts = 3
-Credential $Credential ` $delay = 10 # seconds between attempts
-SessionOption $sessionOptions ` for ($i = 1; $i -le $attempts; $i++) {
-UseSSL ` try {
-Port 5986 ` $session = New-PSSession `
-Authentication Basic ` -ComputerName $IPAddress `
-ErrorAction Stop -Credential $Credential `
-SessionOption $sessionOptions `
-UseSSL `
-Port 5986 `
-Authentication Basic `
-ErrorAction Stop
break
} catch {
if ($i -eq $attempts) { throw }
Write-Warning "[Get-BuildArtifacts] WinRM connect attempt $i/$attempts failed — retrying in ${delay}s... ($_)"
Start-Sleep -Seconds $delay
}
}
try { try {
# ── Verify artifact exists in guest ────────────────────────────────── # ── Verify artifact exists in guest ──────────────────────────────────