vscode/build/azure-pipelines/win32/retry.ps1

20 lines
230 B
PowerShell
Raw Normal View History

2020-11-24 19:22:28 +08:00
function Retry
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd
)
$retry = 0
while ($retry++ -lt 3) {
try {
& $cmd
return
} catch {
2020-11-27 18:30:34 +08:00
# noop
2020-11-24 19:22:28 +08:00
}
}
throw "Max retries reached"
}