简体   繁体   English

Thoughtworks Go:将环境变量传递给任务

[英]Thoughtworks go: pass environment variable to a task

How can I pass the GO environment variable to a task. 如何将GO环境变量传递给任务。 ie

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

I want the GO_Pipeline_counter to be replaced with the actual value ie 56. 我希望将GO_Pipeline_counter替换为实际值,即56。

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 Cmd

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

You should wrap environment variables with '%'. 您应该用'%'包裹环境变量。 Eg: 例如:

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

The braces characters (as in ${VAR} ) do not work in GoCD tasks. 花括号字符(如${VAR} )在GoCD任务中不起作用。 You really must only use the dollar sign without braces (as in $VAR ) for correct replacement of a variable with its value. 您实际上只必须使用不带花括号的美元符号(如$VAR )来正确替换变量的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM