Reputation: 859
I'm building an application with CircleCI and I'm looking to echo an environment variable to the $BASH_ENV so that it will persist between CircleCI steps.
A working example of this is:
echo 'export TEST_NAME=$( cat dockername.txt )' >> $BASH_ENV
Which will allow the TEST_NAME to be correctly loaded in the following CircleCI steps. I'm now looking to do the same but with the variable being equal to an existing environment variable.
export VAR=FOO
echo $VAR // outputs 'FOO'
echo 'export TOKEN=$VAR' >> $BASH_ENV
// TOKEN outputs null in same and subsequent steps. I need it to equal FOO
I've tried every variation of syntax for this to work but I can't seem to crack it. Any thoughts?
Upvotes: 0
Views: 1356
Reputation: 2105
echo "export TOKEN=${VAR}" >> $BASH_ENV
Use double quotes to have the variable evaluated. The braces aren't necessary but are good practice.
Upvotes: 2