From 6a7d12d7845d2a6d4b641e1a55ac051756375691 Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Fri, 7 May 2021 18:38:34 -0700 Subject: [PATCH] Add better error handling in Prepare-Release --- eng/common/scripts/Prepare-Release.ps1 | 5 +++++ eng/common/scripts/Update-DevOps-Release-WorkItem.ps1 | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/Prepare-Release.ps1 b/eng/common/scripts/Prepare-Release.ps1 index b3b62e9f96e..2c7b6152204 100644 --- a/eng/common/scripts/Prepare-Release.ps1 +++ b/eng/common/scripts/Prepare-Release.ps1 @@ -136,6 +136,11 @@ if ($null -eq $newVersionParsed) -packageType $packageProperties.SDKType ` -packageNewLibrary $packageProperties.IsNewSDK +if ($LASTEXITCODE -ne 0) { + Write-Error "Updating of the Devops Release WorkItem failed." + exit 1 +} + if ($releaseTrackingOnly) { Write-Host diff --git a/eng/common/scripts/Update-DevOps-Release-WorkItem.ps1 b/eng/common/scripts/Update-DevOps-Release-WorkItem.ps1 index 92f9a41106a..b1a45abffa2 100644 --- a/eng/common/scripts/Update-DevOps-Release-WorkItem.ps1 +++ b/eng/common/scripts/Update-DevOps-Release-WorkItem.ps1 @@ -19,11 +19,17 @@ param( Set-StrictMode -Version 3 if (!(Get-Command az -ErrorAction SilentlyContinue)) { - Write-Host 'You must have the Azure CLI installed: https://aka.ms/azure-cli' + Write-Error 'You must have the Azure CLI installed: https://aka.ms/azure-cli' exit 1 } -az extension show -n azure-devops > $null +az account show *> $null +if (!$?) { + Write-Host 'Running az login...' + az login *> $null +} + +az extension show -n azure-devops *> $null if (!$?){ Write-Host 'Installing azure-devops extension' az extension add --name azure-devops