Sync eng/common directory with azure-sdk-tools repository (#83)
This commit is contained in:
parent
110110a43f
commit
9ceee65a6d
@ -172,19 +172,20 @@ if ($TestApplicationId -and !$TestApplicationOid) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# If the ServiceDirectory is an absolute path use the last directory name
|
||||
# (e.g. D:\foo\bar\ -> bar)
|
||||
$serviceName = if (Split-Path -IsAbsolute $ServiceDirectory) {
|
||||
Split-Path -Leaf $ServiceDirectory
|
||||
} else {
|
||||
$ServiceDirectory
|
||||
}
|
||||
|
||||
# Format the resource group name based on resource group naming recommendations and limitations.
|
||||
$resourceGroupName = if ($CI) {
|
||||
$BaseName = 't' + (New-Guid).ToString('n').Substring(0, 16)
|
||||
Write-Verbose "Generated base name '$BaseName' for CI build"
|
||||
|
||||
# If the ServiceDirectory is an absolute path use the last directory name
|
||||
# (e.g. D:\foo\bar\ -> bar)
|
||||
$serviceName = if (Split-Path -IsAbsolute $ServiceDirectory) {
|
||||
Split-Path -Leaf $ServiceDirectory
|
||||
} else {
|
||||
$ServiceDirectory
|
||||
}
|
||||
|
||||
"rg-{0}-$BaseName" -f ($serviceName -replace '[\\\/:]', '-').Substring(0, [Math]::Min($serviceName.Length, 90 - $BaseName.Length - 4)).Trim('-')
|
||||
} else {
|
||||
"rg-$BaseName"
|
||||
@ -286,7 +287,21 @@ foreach ($templateFile in $templateFiles) {
|
||||
Log "Persist the following environment variables based on your detected shell ($shell):`n"
|
||||
}
|
||||
|
||||
$deploymentOutputs = @{}
|
||||
$serviceDirectoryPrefix = $serviceName.ToUpperInvariant() + "_"
|
||||
|
||||
$context = Get-AzContext;
|
||||
|
||||
# Add default values
|
||||
$deploymentOutputs = @{
|
||||
"$($serviceDirectoryPrefix)CLIENT_ID" = $TestApplicationId;
|
||||
"$($serviceDirectoryPrefix)CLIENT_SECRET" = $TestApplicationSecret;
|
||||
"$($serviceDirectoryPrefix)TENANT_ID" = $context.Tenant.Id;
|
||||
"$($serviceDirectoryPrefix)SUBSCRIPTION_ID" = $context.Subscription.Id;
|
||||
"$($serviceDirectoryPrefix)RESOURCE_GROUP" = $resourceGroup.ResourceGroupName;
|
||||
"$($serviceDirectoryPrefix)LOCATION" = $resourceGroup.Location;
|
||||
"$($serviceDirectoryPrefix)ENVIRONMENT" = $context.Environment;
|
||||
}
|
||||
|
||||
foreach ($key in $deployment.Outputs.Keys) {
|
||||
$variable = $deployment.Outputs[$key]
|
||||
|
||||
@ -295,16 +310,21 @@ foreach ($templateFile in $templateFiles) {
|
||||
|
||||
if ($variable.Type -eq 'String' -or $variable.Type -eq 'SecureString') {
|
||||
$deploymentOutputs[$key] = $variable.Value
|
||||
}
|
||||
}
|
||||
|
||||
if ($CI) {
|
||||
# Treat all ARM template output variables as secrets since "SecureString" variables do not set values.
|
||||
# In order to mask secrets but set environment variables for any given ARM template, we set variables twice as shown below.
|
||||
Write-Host "Setting variable '$key': ***"
|
||||
Write-Host "##vso[task.setvariable variable=_$key;issecret=true;]$($variable.Value)"
|
||||
Write-Host "##vso[task.setvariable variable=$key;]$($variable.Value)"
|
||||
} else {
|
||||
Write-Host ($shellExportFormat -f $key, $variable.Value)
|
||||
}
|
||||
foreach ($key in $deploymentOutputs.Keys)
|
||||
{
|
||||
$value = $deploymentOutputs[$key]
|
||||
|
||||
if ($CI) {
|
||||
# Treat all ARM template output variables as secrets since "SecureString" variables do not set values.
|
||||
# In order to mask secrets but set environment variables for any given ARM template, we set variables twice as shown below.
|
||||
Write-Host "Setting variable '$key': ***"
|
||||
Write-Host "##vso[task.setvariable variable=_$key;issecret=true;]$($value)"
|
||||
Write-Host "##vso[task.setvariable variable=$key;]$($value)"
|
||||
} else {
|
||||
Write-Host ($shellExportFormat -f $key, $value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user