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 ──────────────────────────────────