microsoft / azure-pipelines-terraform

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

Move -detailed-exitcode flag or add option to disable it from automatically being added to the end of a plan task #226

Open sam-rooke-ppb opened 1 week ago

sam-rooke-ppb commented 1 week ago

I want to add extra commands to the end of my terraform plan script, but I get the Too many command line arguments error due to -detailed-exitcode being added to the end of the command.

Here's the example I'm working with:

      - task: TerraformTaskV4@4
        displayName: 'Terraform Plan'
        inputs:
          provider: 'aws'
          command: 'plan'
          commandOptions: '-out="test.tfplan" > tf_plan.txt'
          workingDirectory: '$(System.DefaultWorkingDirectory)/terraform'
          environmentServiceNameAWS: 'aws-service-name'

Change request

Either one of:

  1. The -detailed-exitcode flag to be added automatically as the first flag before attaching the user specified commandOptions
  2. There to be an inputProperty to disable the -detailed-exitcode flag

Actual behaviour

The command output looks like:

terraform plan -out="test.tfplan" > tf_plan.txt -detailed-exitcode

Expected behaviour

The command output to look like:

terraform plan -detailed-exitcode -out="test.tfplan" > tf_plan.txt

Or to be able to specify an input option so the task will look like:

      - task: TerraformTaskV4@4
        displayName: 'Terraform Plan'
        inputs:
          provider: 'aws'
          command: 'plan'
          commandOptions: '-out="test.tfplan" > tf_plan.txt'
          workingDirectory: '$(System.DefaultWorkingDirectory)/terraform'
          environmentServiceNameAWS: 'aws-service-name'
          detailedExitCode: false