Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 3124 (#28158)
Browse files Browse the repository at this point in the history
* 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 <bebroder@microsoft.com>
  • Loading branch information
azure-sdk and benbp committed Apr 12, 2022
1 parent 15f55a0 commit bba0666
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions eng/common/TestResources/Remove-TestResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,15 @@ $context = Get-AzContext

if (!$ResourceGroupName) {
if ($CI) {
if (!$ServiceDirectory) {
Write-Warning "ServiceDirectory parameter is empty, nothing to remove"
exit 0
}
$envVarName = (BuildServiceDirectoryPrefix (GetServiceLeafDirectoryName $ServiceDirectory)) + "RESOURCE_GROUP"
$ResourceGroupName = [Environment]::GetEnvironmentVariable($envVarName)
if (!$ResourceGroupName) {
Write-Error "Could not find resource group name environment variable '$envVarName'"
exit 1
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."
exit 0
}
} else {
if (!$BaseName) {
Expand Down
2 changes: 1 addition & 1 deletion eng/common/TestResources/SubConfig-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function BuildServiceDirectoryPrefix([string]$serviceName) {
# If the ServiceDirectory has multiple segments use the last directory name
# e.g. D:\foo\bar -> bar or foo/bar -> bar
function GetServiceLeafDirectoryName([string]$serviceDirectory) {
return Split-Path -Leaf $serviceDirectory
return $serviceDirectory ? (Split-Path -Leaf $serviceDirectory) : ""
}

function GetUserName() {
Expand Down

0 comments on commit bba0666

Please sign in to comment.