[stable-2.7] Add retries for Invoke-ScriptAnalyzer in pslint.

Hopefully this will work around the intermittent CI failures due
to NullReferenceException, which then succeed on a retry.
(cherry picked from commit 4bd60c313b)

Co-authored-by: Matt Clay <matt@mystile.com>
pull/50449/head
Matt Clay 6 years ago
parent 6e93965528
commit 55889a9a60

@ -4,11 +4,25 @@
Set-StrictMode -Version 2.0
$ErrorActionPreference = "Stop"
$WarningPreference = "Stop"
$Results = @()
ForEach ($Path in $Args) {
$Results += Invoke-ScriptAnalyzer -Path $Path -Setting $PSScriptRoot/settings.psd1
$Retries = 3
Do {
Try {
$Results += Invoke-ScriptAnalyzer -Path $Path -Setting $PSScriptRoot/settings.psd1 3> $null
$Retries = 0
}
Catch {
If (--$Retries -le 0) {
Throw
}
}
}
Until ($Retries -le 0)
}
ConvertTo-Json -InputObject $Results

Loading…
Cancel
Save