[英]How to output terraform output file in Azure DevOps in release pipeline
How to output Terraform output file in Azure DevOps in release pipeline.如何在发布管道中的 Azure DevOps 中输出 Terraform 输出文件。 I am using Run Terraform task in Release pipeline.我在发布管道中使用运行 Terraform 任务。 I have a output file in Repo which outputs public IPs.我在 Repo 中有一个输出文件,它输出公共 IP。 I want to store it as Variable which can be used in further tasks.我想将它存储为可用于进一步任务的变量。
For this issue ,it can be done with a simple output and powershell script:对于这个问题,可以通过一个简单的输出和 powershell 脚本来完成:
1.Specify the output variable from terraform task 1.指定terraform任务的输出变量
2.Create a PowerShell step in your release and insert the following script: 2.在您的版本中创建一个 PowerShell 步骤并插入以下脚本:
$json = Get-Content $env:jsonPath | Out-String | ConvertFrom-Json
foreach($prop in $json.psobject.properties) {
Write-Host("##vso[task.setvariable variable=$($prop.Name);]$($prop.Value.value)")
}
This will automatically create a variable for every output provided by the terraform
script.这将自动为terraform
脚本提供的每个输出创建一个变量。
Make sure you have provided the environment variable jsonPath like this:确保您提供了这样的环境变量 jsonPath:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.