microsoft / azure-pipelines-terraform

Azure Pipelines tasks for installing Terraform and running Terraform commands in a build or release pipeline.
MIT License
101 stars 62 forks source link

Unable to redirect the output values of outputs.tf file to a different file from azure-pipelines.yaml #140

Open ssubhro opened 1 year ago

ssubhro commented 1 year ago

I am trying to redirect the output values of outputs.tf file to a different file from the azure-pipelines.yaml. To achieve that I am using an AzurePowershell task on the pipeline yaml. PFB.

**- stage: terraform_output dependsOn: ["infrastructure_creation"] jobs:

But this isn't working. Getting the below error.

Exception: /home/vsts-agent/ansibleadoagent/_work/_tasks/AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62/5.218.0/InitializeAz.ps1:38 Line | 38 | throw ("Could not find the module Az.Accounts with given version. … | ~~~~~~~~~~~~~ | Could not find the module Az.Accounts with given version. If the module | was recently installed, retry after restarting the Azure Pipelines task | agent.

To check if the script is correct or not I tried by echoing "Hello-World" to the required file. Even though the stage was successful, the output.json file never got modified/updated.

Inline: | Write-Output "Hello-World" > $(System.DefaultWorkingDirectory)\ansible-roles\inventory\output.json

Need help on resolving this particular issue.

mericstam commented 1 year ago

Hello, the reference TerraformOutput.jsonOutputVariablesPath does not seen right. I dont see TerraformOutput as a name of your output step. check syntax at https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-variables-scripts?view=azure-devops&tabs=bash#levels-of-output-variables