From 17261a26bf8979b4b3bf92e3af8d931f4abd2ad1 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:12:45 -0700 Subject: [PATCH] Set resource group env variable early so remove always works (#2943) Co-authored-by: Ben Broderick Phillips --- eng/common/TestResources/New-TestResources.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index dbb8c4f20..2958ccc66 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -350,6 +350,10 @@ try { # to determine whether resources should be removed. Write-Host "Setting variable 'CI_HAS_DEPLOYED_RESOURCES': 'true'" LogVsoCommand "##vso[task.setvariable variable=CI_HAS_DEPLOYED_RESOURCES;]true" + # Set resource group env variable early in cases where deployment fails as we + # still want to clean up the group. The Remove-TestResources.ps1 script consumes this var. + $envVarName = (BuildServiceDirectoryPrefix $serviceName) + "RESOURCE_GROUP" + LogVsoCommand "##vso[task.setvariable variable=$envVarName;]$ResourceGroupName" } Log "Creating resource group '$ResourceGroupName' in location '$Location'"