From b5a05e45d5c3a86fcb19ef80b20d7556d8de6e69 Mon Sep 17 00:00:00 2001 From: Nikolay Frolov Date: Tue, 12 Oct 2021 10:35:17 +0300 Subject: [PATCH 1/3] Change way for versions-manifest.json gathering --- packages-generation/manifest-validator.ps1 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages-generation/manifest-validator.ps1 b/packages-generation/manifest-validator.ps1 index 9daf876..bb64643 100644 --- a/packages-generation/manifest-validator.ps1 +++ b/packages-generation/manifest-validator.ps1 @@ -1,5 +1,5 @@ param ( - [Parameter(Mandatory)][string] $ManifestUrl, + [Parameter(Mandatory)][string] $ManifestPath, [string] $AccessToken ) @@ -38,19 +38,16 @@ function Test-DownloadUrl { } } -Write-Host "Downloading manifest json from '$ManifestUrl'..." -try { - $manifestResponse = Invoke-WebRequest -Method Get -Uri $ManifestUrl -Headers $webRequestHeaders -MaximumRetryCount 5 -RetryIntervalSec 10 -} catch { - Publish-Error "Unable to download manifest json from '$ManifestUrl'" $_ +if (-not (Test-Path $ManifestPath)) { + Publish-Error "Unable to find manifest json file at '$ManifestPath'" exit 1 } -Write-Host "Parsing manifest json content from '$ManifestUrl'..." +Write-Host "Parsing manifest json content from '$ManifestPath'..." try { - $manifestJson = $manifestResponse.Content | ConvertFrom-Json + $manifestJson = $( Get-Content $ManifestPath ) | ConvertFrom-Json } catch { - Publish-Error "Unable to parse manifest json content '$ManifestUrl'" $_ + Publish-Error "Unable to parse manifest json content '$ManifestPath'" $_ exit 1 } From fa4964171990762315b9c1ad5f2406362d4b0fe0 Mon Sep 17 00:00:00 2001 From: "Nikolai Frolov (Akvelon INC)" Date: Tue, 12 Oct 2021 16:00:52 +0300 Subject: [PATCH 2/3] Minor code improvement according to comments --- packages-generation/manifest-validator.ps1 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages-generation/manifest-validator.ps1 b/packages-generation/manifest-validator.ps1 index bb64643..043eca5 100644 --- a/packages-generation/manifest-validator.ps1 +++ b/packages-generation/manifest-validator.ps1 @@ -4,11 +4,6 @@ param ( ) $Global:validationFailed = $false -$authorizationHeaderValue = "Basic $AccessToken" -$webRequestHeaders = @{} -if ($AccessToken) { - $webRequestHeaders.Add("Authorization", $authorizationHeaderValue) -} function Publish-Error { param( @@ -16,7 +11,7 @@ function Publish-Error { [object] $Exception ) - echo "::error ::$ErrorDescription" + Write-Output "::error ::$ErrorDescription" if (-not [string]::IsNullOrEmpty($Exception)) { Write-Output "Exception: $Exception" @@ -26,6 +21,7 @@ function Publish-Error { function Test-DownloadUrl { param([string] $DownloadUrl) + $authorizationHeaderValue = "Basic $AccessToken" $request = [System.Net.WebRequest]::Create($DownloadUrl) if ($AccessToken) { $request.Headers.Add("Authorization", $authorizationHeaderValue) From 359c2548cb61c09363a4be0f820f19ae34ddaba5 Mon Sep 17 00:00:00 2001 From: "Nikolai Frolov (Akvelon INC)" Date: Tue, 12 Oct 2021 17:19:45 +0300 Subject: [PATCH 3/3] Minor code improvement according to comments --- packages-generation/manifest-validator.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages-generation/manifest-validator.ps1 b/packages-generation/manifest-validator.ps1 index 043eca5..e2fd71c 100644 --- a/packages-generation/manifest-validator.ps1 +++ b/packages-generation/manifest-validator.ps1 @@ -20,10 +20,10 @@ function Publish-Error { } function Test-DownloadUrl { - param([string] $DownloadUrl) - $authorizationHeaderValue = "Basic $AccessToken" + param([string] $DownloadUrl) $request = [System.Net.WebRequest]::Create($DownloadUrl) if ($AccessToken) { + $authorizationHeaderValue = "Basic $AccessToken" $request.Headers.Add("Authorization", $authorizationHeaderValue) } try { @@ -41,7 +41,7 @@ if (-not (Test-Path $ManifestPath)) { Write-Host "Parsing manifest json content from '$ManifestPath'..." try { - $manifestJson = $( Get-Content $ManifestPath ) | ConvertFrom-Json + $manifestJson = Get-Content $ManifestPath | ConvertFrom-Json } catch { Publish-Error "Unable to parse manifest json content '$ManifestPath'" $_ exit 1