Skip to content

Commit d244685

Browse files
azure-sdkbenbp
andauthored
Sync eng/common directory with azure-sdk-tools for PR 3124 (Azure#21348)
* Do not fail remove test resources step when env var is not set. * Handle empty service directories in remove test resources script Co-authored-by: Ben Broderick Phillips <[email protected]>
1 parent f77ec27 commit d244685

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

eng/common/TestResources/Remove-TestResources.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,15 @@ $context = Get-AzContext
132132

133133
if (!$ResourceGroupName) {
134134
if ($CI) {
135+
if (!$ServiceDirectory) {
136+
Write-Warning "ServiceDirectory parameter is empty, nothing to remove"
137+
exit 0
138+
}
135139
$envVarName = (BuildServiceDirectoryPrefix (GetServiceLeafDirectoryName $ServiceDirectory)) + "RESOURCE_GROUP"
136140
$ResourceGroupName = [Environment]::GetEnvironmentVariable($envVarName)
137141
if (!$ResourceGroupName) {
138-
Write-Error "Could not find resource group name environment variable '$envVarName'"
139-
exit 1
142+
Write-Error "Could not find resource group name environment variable '$envVarName'. This is likely due to an earlier failure in the 'Deploy Test Resources' step above."
143+
exit 0
140144
}
141145
} else {
142146
if (!$BaseName) {

eng/common/TestResources/SubConfig-Helpers.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function BuildServiceDirectoryPrefix([string]$serviceName) {
55
# If the ServiceDirectory has multiple segments use the last directory name
66
# e.g. D:\foo\bar -> bar or foo/bar -> bar
77
function GetServiceLeafDirectoryName([string]$serviceDirectory) {
8-
return Split-Path -Leaf $serviceDirectory
8+
return $serviceDirectory ? (Split-Path -Leaf $serviceDirectory) : ""
99
}
1010

1111
function GetUserName() {

0 commit comments

Comments
 (0)