From 4bd60c313bac585ca012d9729fac8e65da4b2c67 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 19 Dec 2018 09:53:15 -0800 Subject: [PATCH] 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. --- test/sanity/pslint/pslint.ps1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/sanity/pslint/pslint.ps1 b/test/sanity/pslint/pslint.ps1 index 8f7beab2941..ac8e65771e2 100755 --- a/test/sanity/pslint/pslint.ps1 +++ b/test/sanity/pslint/pslint.ps1 @@ -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