Project Environment Variable Is Not Replaced

Hi, I have a project environment variable named CODECOV_TOKEN and I am trying to use it as part of the following command:

- run:
    command: codecov -f "**/coverage.opencover.xml" -t ${CODECOV_TOKEN}

This results in an error:

ERROR(S):
    Option 't, token' has no value.

Which indicates the environment variable is not being replaced. I am trying the same command with $CODECOV_TOKEN which produces the same result.

The following command:

  - run:
      name: "test env var"
      command: |
        echo ${CODECOV_TOKEN}

Produces this output (also tried with $CODECOV_TOKEN):

#!powershell.exe -ExecutionPolicy Bypass
echo ${CODECOV_TOKEN}

CircleCI received exit code 0

This also suggests the environment variable is not being replaced.

Could you please help me to find the reason and fix the replacement?

Thanks!

Hello @serhatozgel. Welcome to the CircleCI Discuss community!

Looking at the output you shared, I see that you’re using the Windows executor with the default shell powershell.exe -ExecutionPolicy Bypass.

Therefore you’ll need to use the following syntax to interpolate the variable:

$env:CODECOV_TOKEN

Thanks for the reply, @yannCI. I tried your suggestion and it works!

1 Like

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