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:
parent
ca20a7f744
commit
7889304391
@ -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) {
|
||||
|
||||
@ -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() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user