From 1998f3b3662d2d159b1e43c23a37b7e709d93cf5 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 7 May 2021 23:34:44 -0400 Subject: [PATCH] Add better error handling in Prepare-Release (#18590) Co-authored-by: Wes Haggard --- 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 b3b62e9f96e9..2c7b61522048 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 92f9a41106ad..b1a45abffa2e 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