How to Resolve Environment Variables in Thoughtworks Go Task Command

Thoughtworks Go provides a stack of job-specific work variables for each task. For example my work outputs the same values ​​as API doc .

[go] setting environment variable 'GO_ENVIRONMENT_NAME' to value 'rmp'
[go] setting environment variable 'a' to value 'b'
[go] setting environment variable 'GO_SERVER_URL' to value 'https://10.8.249.57:8154/go/'

      

I was unable to resolve vars in the bash task command.

[go] Start to execute task: <exec command="echo" >
<arg>${GO_SERVER_URL}</arg>

      

Just outputs

${GO_SERVER_URL}

      

I tried...

${GO_SERVER_URL}
${env.GO_SERVER_URL}
${go.GO_SERVER_URL}
$[GO_SERVER_URL]
$GO_SERVER_URL
"${GO_SERVER_URL}"

      

nothing works...

+3


source to share


2 answers


Thoughtworks Go has a support page about this exact issue , which says:

Note that this is a simple exec, not an exec, so [$ FOO] will not have the desired effect

Simplest solution:



command: /bin/bash

args:
-c
echo
$GO_SERVER_URL

      

The alternative is to just toss your script into a file.

Why do I know this? Because I ran into this too.

+4


source


For a team with multiple options, Go is pretty sophisticated. tedder42's answer was correct for a simple echo case, but didn't work for me for my real problem using multi-parameter curl. Srinivas Upadhya on Go to Google Group helped me. I want to document it here for others, so it's easy to find. It looks obvious, but small deviations didn't work.

Enter the command exactly like this: enter image description here



XML should look like this:

<tasks>
  <exec command="/bin/bash">
    <arg>-c</arg>
    <arg>curl -o test.file $GO_VAR</arg>
    <runif status="passed" />
  </exec>
  ....
</tasks>

      

+1


source







All Articles