[英]Passing Terraform output to Powershell task in Azure Devosps
在 Azure DevOps 中,我們有以下YAML
管道,它從CmdLine
任務應用 Terraform 配置。 Output 任務在Terraform
部署后應返回Data Factory
的 ObjectId。 我想使用該 ObjectId 並將其作為參數傳遞給下一個Azure Powershell Task
,以便我可以將該 ID 作為成員添加到 AzureADGroup。 如何在下一個Powershell
任務中使用名為“Terraform 輸出”的步驟中的 output?
- task: CmdLine@2
displayName: Terraform Apply
enabled: False
inputs:
script: terraform apply -auto-approve -input=false tfplan
workingDirectory: infrastructure/tf_scripts/dev
- task: CmdLine@2
displayName: Terraform output
enabled: False
inputs:
script: |
terraform output adf_objectid
workingDirectory: infrastructure/tf_scripts/dev
- task: AzurePowerShell@4
displayName: 'Azure PowerShell script: InlineScript'
inputs:
azureSubscription: 'a6cb1cd3-8d5e-4db6-8af5-bcb66492d5cc'
ScriptType: 'InlineScript'
Inline: |
$spn=(terraform output adf_objectid)
Connect-AzureAD -AadAccessToken $aadToken -AccountId $context.Account.Id -TenantId $context.tenant.id -MsAccessToken $graphToken
Add-AzureADGroupMember -ObjectId xxxxx-xxxxx-xxxxx -RefObjectId $spn
workingDirectory: wd/scripts/dev
azurePowerShellVersion: 'LatestVersion'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.