Thoughtworks go: pass environment variable to a task

596 Views Asked by At

How can I pass the GO environment variable to a task. ie

grunt build-discovery-dev --buildNumber=" ${GO_PIPELINE_COUNTER}.   

I want the GO_Pipeline_counter to be replaced with the actual value ie 56.

3

There are 3 best solutions below

0
On

The braces characters (as in ${VAR}) do not work in GoCD tasks. You really must only use the dollar sign without braces (as in $VAR) for correct replacement of a variable with its value.

0
On

Depends on where you invoke the command from

Shell

grunt build-discovery-dev --buildNumber=$GO_PIPELINE_COUNTER

Powershell

grunt build-discovery-dev --buildNumber=$env:GO_PIPELINE_COUNTER

Cmd

grunt build-discovery-dev --buildNumber=%GO_PIPELINE_COUNTER%
0
On

You should wrap environment variables with '%'. E.g.:

grunt build-discovery-dev --buildNumber=" %GO_PIPELINE_COUNTER%.