From d1f267b67c829e5000d748eb501f435b9e4f2566 Mon Sep 17 00:00:00 2001 From: Simone Date: Sun, 10 May 2026 22:23:11 +0200 Subject: [PATCH] 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 --- scripts/Get-BuildArtifacts.ps1 | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/scripts/Get-BuildArtifacts.ps1 b/scripts/Get-BuildArtifacts.ps1 index 6ecce9a..a8cbbd7 100644 --- a/scripts/Get-BuildArtifacts.ps1 +++ b/scripts/Get-BuildArtifacts.ps1 @@ -68,14 +68,26 @@ if (-not (Test-Path $HostArtifactDir)) { $sessionOptions = New-CISessionOption Write-Host "[Get-BuildArtifacts] Connecting to VM at $IPAddress..." -$session = New-PSSession ` - -ComputerName $IPAddress ` - -Credential $Credential ` - -SessionOption $sessionOptions ` - -UseSSL ` - -Port 5986 ` - -Authentication Basic ` - -ErrorAction Stop +$session = $null +$attempts = 3 +$delay = 10 # seconds between attempts +for ($i = 1; $i -le $attempts; $i++) { + try { + $session = New-PSSession ` + -ComputerName $IPAddress ` + -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 { # ── Verify artifact exists in guest ──────────────────────────────────