Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
"scriptType": "filePath",
"scriptName": "$(Build.SourcesDirectory)\\build\\buildpipeline\\security\\Get-LatestVersion.ps1",
"arguments": "-Branch \"$(CodeBase)\"",
"workingFolder": "$(Build.SourcesDirectory)\\$(PB_Repo)\\build\\buildpipeline\\security\\",
"workingFolder": "",
"failOnStandardError": "true"
}
},
Expand Down
7 changes: 4 additions & 3 deletions build/buildpipeline/security/Get-LatestVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ function Get-VersionInfo
$retryCount = 1
$oldEap = $ErrorActionPreference

while ($retryCount -le 3)
while ($retryCount -le $retries)
{
$ErrorActionPreference = "Stop"

try
{
return (Invoke-WebRequest -Uri "$latestVersionUrl" -UseBasicParsing).Content.Split([Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries)
$content = (Invoke-WebRequest -Uri "$latestVersionUrl" -UseBasicParsing).Content
return $content.Split([Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries)
}
catch
{
Expand All @@ -53,7 +54,7 @@ function Get-VersionInfo
$latestVersionUrl = "$UrlPrefix/$Branch/$Filename"
$latestVersionContent = Get-VersionInfo

if (-not [string]::IsNullOrWhiteSpace($latestVersionContent) -and $latestVersionContent.Length -eq 2)
if ($latestVersionContent -ne $null -and $latestVersionContent.Length -eq 2)
{
$CliLatestCommitSha = $latestVersionContent[0]
$CliLatestPackageId = $latestVersionContent[1]
Expand Down