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:
@@ -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 ──────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user