How to use variables from a bash script within a CircleCI config?


I have a bash script that looks like this :-


stage=$(echo "${username}" | sed 's/[^a-zA-Z]//g' | tr "[:upper:]" "[:lower:]")
echo "${stage}"

and i want to use the stage variable in my circleci job.

I am invoking the bash script like this :-

- run:
          name: "Update config file with stage name"
          command: |
            chmod 755 ./.circleci/

            # run my script
            ./.circleci/ "$CIRCLE_USERNAME"
            sed -i "s~PLACEHOLDER~$stage~g" config.yaml

But the $stage is empty. I even tried stage=$(./.circleci/ "$CIRCLE_USERNAME") and that did not work either. Any suggestion on how i can make it work. Thank you.

stage=$(./.circleci/ "$CIRCLE_USERNAME") works. I just wasn’t referencing it properly.

1 Like

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