Passing environment variable to orb command

Hi,

I have a command that is using a string parameter that will be stored as en environment variable so that the include script can use it.
Here is the command:

sre-utils/test

parameters:
  registry_user:
    default: ''
    type: string

steps:
  - run:
      name: test
      command: echo << parameters.registry_user >>

  - run:
      name: test2
      environment:
        CONTAINER_REGISTRY_USER: << parameters.registry_user >>
      command: << include(myscript.sh) >>

myscript.sh

#!/bin/bash
echo "${CONTAINER_REGISTRY_USER}"

And I’m calling it by passing the following to the job:

      - sre-utils/test:
          registry_user: ${MY_VAR}

However, if test will echo “*******”, test2 will output

+ echo '${CONTAINER_REGISTRY_USER}'
${MY_VAR}

Do you know what I’m doing wrong here ?

The “******” output within the logs is normal as the system tries its very best to hide all parameters and job-based environment variables as a security measure. It’s a nice feature, but a real pain when trying to debug things.

This hiding process does not take place on variables that are defined within bash scripts as the build process is not tracking the assigned values. More details can be found here

Hey, thanks for the answer.
My question is mainly why am I seeing ${MY_VAR} and not the actual value like if foo if MY_VAR=foo.
Do you have an idea why ?

OK, I missed that part

The circleci script environment is not a Linux shell, with the result that it does not currently do environment variable expansion as you would hope/expect. So passing ${MY_VAR} will pass “${MY_VAR}” rather than the value of MY_VAR. Circleci states

" In general, CircleCI does not support interpolating environment variable into build config. Values used are treated as literals. This can cause issues when defining working_directory, modifying PATH, and sharing variables across multiple run steps."

Thanks, I’ll revert back to not using the script then.

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