Concourse: vars vs params

2.1k Views Asked by At

Concourse provides two concepts: vars and params. Both of them can be used to pass some values inside of a task.

      params:
        COMMAND: deployment.deploy
      vars:
        command: deployment.deploy

When should use params? is there any rule of thumb?

1

There are 1 best solutions below

0
On

params are an optional configuration of the task schema. tasks#params

A key-value mapping of string keys and values that are exposed to the task via environment variables.

task: env
config:
  platform: linux
  image_resource:
    type: registry-image
    source:
      repository: alpine
  params:
    VALUE: something
  run:
    path: sh
    args:
      - -c
      - echo $VALUE

vars can be used in most parts of the task configuration. vars

Aside from credentials, vars may also be used for generic parameterization of pipeline configuration templates, allowing a single pipeline config file to be configured multiple times with different parameters - e.g. ((branch_name)).

task: env
config:
  platform: linux
  image_resource:
    type: registry-image
    source:
      repository: my-image
      tag: ((branch_name))
  params:
    BRANCH_NAME: ((branch_name))
  run:
    path: sh
    args:
      - -c
      - echo $BRANCH_NAME; echo 'can also be interpolated here: ((branch_name))'