jason-johnson / azure-pipelines-tasks-terraform

Azure Pipelines extension for Terraform
MIT License
121 stars 52 forks source link

Support for global options #383

Closed msglueck closed 9 months ago

msglueck commented 9 months ago

Describe the bug / feature request Terraform supports options and global options. I would like to have a separate runbook in a subfolder and call this from a separate pipeline. Currently the inputs section of a task supports commandOptions which are correctly appended to the end of the command. But global options need to be added before the terraform command. From these global options the chdir would be handy in my use-case. Adding -chdir ./subfolder to the commandOptions creates an error response

Usage: terraform [global options] init [options]

Global options (use these before the subcommand, if any): -chdir=DIR Switch to a different working directory before executing the given subcommand. -help Show this help output, or the help for a specified subcommand. -version An alias for the "version" subcommand.

To Reproduce Steps to reproduce the behavior:

  1. Setup pipeline as (include yaml configuration or screenshots of classic ui editor)
  2. Execute pipeline
  3. set -chdir ./subfolder to the /inputs/commandOptions of a task

Expected behavior the -chdir ./subfolder is added before the terraform command or an optional additional commandOptionsGlobal is available in inputs template

Agent Configuration

Additional context this might end up in a feature request/PR. just wanted to check upfront if this is the preferred way to do so

jason-johnson commented 9 months ago

This is done by setting the workingDirectory field on the task.

msglueck commented 9 months ago

Ok, thx for pointing that out. That was actually the first thing I tried… but the pipeline had another issue that lead to a misleading error. For now moved the subfolder to another repository. Which is my current use-case even cleaner, but will try your suggestion next time! Thanks for the quick response.