From a6fc85c1966780abda357e4164bdf0b4299f6d5b Mon Sep 17 00:00:00 2001 From: Kartheek Penagamuri <52756182+kartheekp-ms@users.noreply.github.com> Date: Fri, 29 Jan 2021 10:57:37 -0800 Subject: [PATCH] read buildinfo json file from build artifact in TagNuGetClientGitRepostoryOnRelease script (#3870) --- .../TagNuGetClientGitRepostoryOnRelease.ps1 | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/utils/TagNuGetClientGitRepostoryOnRelease.ps1 b/scripts/utils/TagNuGetClientGitRepostoryOnRelease.ps1 index d19992f1f..ad56e17b2 100644 --- a/scripts/utils/TagNuGetClientGitRepostoryOnRelease.ps1 +++ b/scripts/utils/TagNuGetClientGitRepostoryOnRelease.ps1 @@ -9,10 +9,13 @@ Uses the Personal Access Token of NuGetLurker to automate the tagging process. PersonalAccessToken of the NuGetLurker account .PARAMETER VsTargetBranch -The VS Branch that the NuGet build is being inserted into. +The VS Branch that the NuGet build is being inserted into. .PARAMETER BuildOutputPath The output path for NuGet Build artifacts. + +.PARAMETER BuildInfoJsonFile +Path to the buildInfo.json file that is published as artifact for every build. #> [CmdletBinding()] @@ -23,7 +26,9 @@ param [Parameter(Mandatory=$True)] [string]$VsTargetBranch, [Parameter(Mandatory=$True)] - [string]$BuildOutputPath + [string]$BuildOutputPath, + [Parameter(Mandatory=$True)] + [string]$BuildInfoJsonFile ) # Set security protocol to tls1.2 for Invoke-RestMethod powershell cmdlet @@ -48,7 +53,6 @@ if($index -ne '-1') $Date = Get-Date $Message = "Insert $ProductVersion into $VsTargetBranch on $Date" -$BuildInfoJsonFile = [System.IO.Path]::Combine($BuildOutputPath, $Branch, $Build, 'buildinfo.json') $buildInfoJson = (Get-Content $BuildInfoJsonFile -Raw) | ConvertFrom-Json $LocRepoCommitHash = $buildInfoJson.LocalizationRepositoryCommitHash @@ -76,12 +80,12 @@ try { type = 'commit'; message= $TagMessage; } | ConvertTo-Json; - + Write-Host $Body - + $tagObject = "refs/tags/$TagName" $r1 = Invoke-RestMethod -Headers $Headers -Method Post -Uri "https://api.github.com/repos/NuGet/$NuGetRepository/git/tags" -Body $Body - Write-Host $r1 + Write-Host $r1 } catch { # The above would fail if the tag already existed, in which case we would append the attempt number to the tag name to make it unique @@ -93,9 +97,9 @@ catch { type = 'commit'; message= $TagMessage; } | ConvertTo-Json; - + Write-Host $Body - + $tagObject = "refs/tags/$TagName" $r1 = Invoke-RestMethod -Headers $Headers -Method Post -Uri "https://api.github.com/repos/NuGet/$NuGetRepository/git/tags" -Body $Body Write-Host $r1