0

We have a requirement to somehow pass a dynamic runtime parameter to a pipeline task. For example below paramater APPROVAL would be different for each run of the task. This APPROVAL parameter is for the change and release number so that the task can tag it on the terraform resources created for audit purposes.

Been searching the web for a while but with no luck in finding a solution, is this possible in a concourse pipeline or best practice?

  - task: plan-terraform
    file: ci/concourse-jobs/pipelines/tasks/terraform/plan-terraform.yaml
    params:
      ENV: dev
      APPROVAL: test
      CHANNEL: Developement
      GITLAB_KEY: ((gitlab_key))
      REGION: eu-west-2
      TF_FOLDER: terraform/squid
    input_mapping:
      ci: ci
      tf: squid
    output_mapping:
      plan: plan
    tags:
    - dev
Alastair Montgomery
  • 1,756
  • 5
  • 21
  • 44

1 Answers1

1

From https://concourse-ci.org/tasks.html: ideally tasks are pure functions: given the same set of inputs, it should either always succeed with the same outputs or always fail.

A dynamic parameter would break that contract and produce different outputs from the same set of inputs. Could you possibly make APPROVAL an input? Then you'd maintain your build traceability. If it's a (file) input, you could then load it into a variable:

APPROVAL=$(cat <filename>)
Brian S
  • 26
  • 1
  • Interesting idea to include the release task in a file, it would mean cutting a new tag for each environment its released to, guessing the approval file could be sourced from another repo though. – Alastair Montgomery Nov 22 '19 at 09:11
  • We have a similar requirement, though approvals are managed through ServiceNow. We're mandating that the deployment artifacts have the change number in them, which our concourse jobs reach out to a ServiceNow API to verify. In your case, a separate repo holding the APPROVAL number (and possibly a commit SHA of what was approved), helps audit as the approval commits themselves will contain the person who approved the change and exactly what they were intending to approve. – Brian S Dec 13 '19 at 17:11