How to access Environment variable in a shell script?

I have added an environment variable in CircleCI and I need to use that variable in a shell script. How do I access the variable?

Variable: XYZ added to environment variable
I need to use XYZ in place of $username in a shell script.

Hi @vinod-1, and welcome to the CircleCI community!

There are several ways to use environment variables within your builds. You can find all usage options outlined in our documentation.

Thanks @yannCI for the reply. I figured out my issue. I had a json inside the shell script the value was a variable. I had to escape it. Here is how it is:

curl -XPOST -d '{"msgtype":"m.text", "body":"'"$CIRCLE_BRANCH in $CIRCLE_PROJECT_REPONAME has failures in job $CIRCLE_JOB. Please fix and publish again"'"}' "myChatURL"


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.