Can't access environment variables in Windows Powershell

Hi!

I’m trying out the newly added Windows support and I am unable to access secret environment variables (set via Project => Build Settings => Environment Variables) when using Powershell.

See below for a minimal repro. In the examples I’ve already set an environment variable TEST_VAR with value test in the web UI.

version: 2.1

orbs:
  win: circleci/windows@1.0.0

jobs:
  build:
    executor:
      name: win/vs2019
      shell: powershell.exe
    environment:
      FOO: "bar"    
    steps:
      - checkout
      - run: Write-Host "Hello $TEST_VAR" # Prints "Hello "
      - run: Write-Host "Hello $FOO" # Prints "Hello "
      - run:
          name: Write-Host
          command: |
            $BAS = "bas"
            Write-Host "Hello $BAS" # Prints "Hello bas"

Note however that this does work with the bash.exe shell:

version: 2.1

orbs:
  win: circleci/windows@1.0.0

jobs:
  build:
    executor:
      name: win/vs2019
      shell: bash.exe
    environment:
      FOO: "bar"    
    steps:
      - checkout
      - run: Write-Host "Hello $FAKE_GCLOUD_SERVICE_KEY" # Prints "Hello test"
      - run: Write-Host "Hello $FOO" # Prints "Hello bar"

At first I thought that this might have to do with CircleCI not printing secrets, but as seen in the second example, that’s not the case. Furthermore the commands that consume the variables all fail.

Thanks for reporting this issue. We are looking into it and will update here if we need more details from you, or if we have an update.