mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
Add retry to Install-RootCA.ps1 generateSSTFromWU (#3018)
* Update Install-RootCA.ps1 added retry behaviour to certutil.exe -generateSSTFromWU * Update Install-RootCA.ps1 removed multi line * fixed pr comments in Install-RootCA.ps1 fixed PR comments
This commit is contained in:
@@ -42,11 +42,32 @@ function Get-CertificatesWithoutPropId {
|
|||||||
}
|
}
|
||||||
$certsWithoutPropId
|
$certsWithoutPropId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Invoke-WithRetry {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Runs $command block until $BreakCondition or $RetryCount is reached.
|
||||||
|
#>
|
||||||
|
|
||||||
|
param([ScriptBlock]$Command, [ScriptBlock] $BreakCondition, [int] $RetryCount=5, [int] $Sleep=10)
|
||||||
|
|
||||||
|
$c = 0
|
||||||
|
while($c -lt $RetryCount){
|
||||||
|
$result = & $Command
|
||||||
|
if(& $BreakCondition){
|
||||||
|
break
|
||||||
|
}
|
||||||
|
Start-Sleep $Sleep
|
||||||
|
$c++
|
||||||
|
}
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
|
||||||
function Import-SSTFromWU {
|
function Import-SSTFromWU {
|
||||||
# Serialized Certificate Store File
|
# Serialized Certificate Store File
|
||||||
$sstFile = "$env:TEMP\roots.sst"
|
$sstFile = "$env:TEMP\roots.sst"
|
||||||
# Generate SST from Windows Update
|
# Generate SST from Windows Update
|
||||||
$result = certutil.exe -generateSSTFromWU $sstFile
|
$result = Invoke-WithRetry { certutil.exe -generateSSTFromWU $sstFile } {$LASTEXITCODE -eq 0}
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Write-Host "[Error]: failed to generate $sstFile sst file`n$result"
|
Write-Host "[Error]: failed to generate $sstFile sst file`n$result"
|
||||||
exit $LASTEXITCODE
|
exit $LASTEXITCODE
|
||||||
|
|||||||
Reference in New Issue
Block a user