【发布时间】:2018-02-09 13:12:41
【问题描述】:
我在 Team Services 中有一个简单的构建设置。该构建只需从 Team Services 托管的 Git 存储库下载源代码,然后执行 Powershell 脚本。
Powershell Script 接收 4 个参数;
-SiteName "$(AppServiceName)" -AzureRMTenantID "$(AzureRMTenantID)" -AzureRMUN "$(AzureRMUN)" -AzureRMPW "$(AzureRMPW)"
AppServiceName 在构建排队时手动输入。
3 个 AzureRM* 参数应该来自我已链接到构建定义的变量组;
变量组 AzureDevOps 配置为将 Azure Key Vault 中的机密链接为变量;
根据我能找到的有关此模式的所有信息,它似乎应该可以工作。
作为临时健全性检查,我在我的 powershell 脚本中打印出变量,以便确认它们被正确传递。
到目前为止,我无法正确打印任何 AzureRM* 变量的值,这让我相信它们没有按预期传递。
Generating script.
Formatted command: . 'd:\a\1\s\AppServices\Create Canned App Service Application.ps1' -SiteName "Testers" -AzureRMTenantID "" -AzureRMUN "" -AzureRMPW ""
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -File "d:\a\_temp\23b9a27a-4b6d-4232-8e24-150173e08915.ps1"
Working Set of Variables:
SiteName: Testers
ResourceGroup: Applications
ASE Name: appservices-ase
Location: East US
Additional Variables:
AzureRMTenantID:
我不希望变量会打印在此处的日志命令中;
Formatted command: . 'd:\a\1\s\AppServices\Create Canned App Service Application.ps1' -SiteName "Testers" -AzureRMTenantID "" -AzureRMUN "" -AzureRMPW ""
但我希望它们会打印在我明确写出的脚本中;
Write-Host "Working Set of Variables:`nSiteName: "$SiteName"`r`nResourceGroup: "$RG"`r`nASE Name: "$ASEName"`r`nLocation: "$Location
Write-Host "Additional Variables:`nAzureRMTenantID: "$AzureRMTenantID"`r`n"$AzureRMUN"`r`n"$AzureRMPW
如果我在本地运行 PS 脚本,值会按预期打印;
PS C:\ashley\scm\AzureAutomation\AppServices> & '.\Create Canned App Service Application.ps1' -SiteName "tester" -AzureRMTenantID 12345 -AzureRMUN user -AzureRMPW 1234
Working Set of Variables:
SiteName: tester
ResourceGroup: Applications
ASE Name: appservices-ase
Location: East US
Additional Variables:
AzureRMTenantID: 12345
user
1234
有谁知道如何进行这项工作?我想知道问题是否与 KeyVault 权限有关,因为请求来自 Team Services 中内置的“Hosted 2017”代理队列。
【问题讨论】:
标签: azure tfs azure-devops azure-pipelines-build-task azure-pipelines-release-pipeline