I am developing Terraform pipeline and i want to set a variable in a stage and then, output it so i can use it in another stage.
So this is my code that works:
stages:
- stage: Terraform_Plan
displayName: Plan
jobs:
- job: Terraform_Plan
displayName: Plan
steps:
- powershell: |
# made it shorter to get a point, that variable set here is not
# respected in next stage
Write-Host "##vso[task.setvariable variable=anyTfChanges;isOutput=true]false"
displayName: Detect any Terraform changes
And in another stage, i want to use it from condition:
stage: Terraform_Apply
displayName: Apply
jobs:
- deployment: Apply
environment: dev
displayName: Apply Terraform
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq('true', 'true'), eq(dependencies.Terraform_Plan.outputs['Terraform_Plan.anyTfChanges'], 'true')))
strategy:
runOnce:
deploy:
steps:
but it looks like that variable is not respected at all because Apply
stage runs all the time, even when i set anyTfChanges
variable to false
Any ideas how to make it works? I use windows agents