mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 22:05:17 +00:00
[Windows] Invoke Move-Item and Rename-Item with retry after Extract-7Zip (#4598)
This commit is contained in:
committed by
GitHub
parent
af645a7b5e
commit
978ab79564
@@ -533,3 +533,29 @@ function Get-WindowsUpdatesHistory {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-SBWithRetry {
|
||||
param (
|
||||
[scriptblock] $Command,
|
||||
[int] $RetryCount = 10,
|
||||
[int] $TimeoutInSecs = 5
|
||||
)
|
||||
|
||||
while ($RetryCount -gt 0) {
|
||||
try {
|
||||
& $Command
|
||||
return
|
||||
}
|
||||
catch {
|
||||
Write-Host "There is an error encounterd:`n $_"
|
||||
$RetryCount--
|
||||
|
||||
if ($RetryCount -eq 0) {
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Waiting $TimeoutInSecs seconds before retrying. Retries left: $RetryCount"
|
||||
Start-Sleep -Seconds $TimeoutInSecs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user