Sync eng/common directory with azure-sdk-tools for PR 3124 (#3546)

* 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>
This commit is contained in:
Azure SDK Bot 2022-04-11 17:28:51 -07:00 committed by GitHub
parent ca20a7f744
commit 7889304391
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -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) {

View File

@ -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() {