concourseconcourse-pipeline

Specify runtime parameter in a pipeline task


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

Solution

  • 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>)