Hi!
I’m very new to CircleCI, and have inherited a partially completed setup that has some shortcomings. As of now, I am trying to start a PowerShell command with different parameters based on the branch name. Problem is that the environment variable seems to be empty in the PowerShell step. I have a debug-step above where I verify that the variable is set, and in that step the variable is populated as expected.
This is a slightly simplified version of my pipeline. What am I doing wrong?
deploy:
machine:
image: windows-default
resource_class: customer_name/cicd02
environment:
APP_SERVER01: ""
steps:
- run:
name: Set AppServers
command: |
if [ "$CIRCLE_BRANCH" == "dev" ]; then
echo "export APP_SERVER01=devServer" >> $BASH_ENV
elif [ "$CIRCLE_BRANCH" == "test" ]; then
echo "export APP_SERVER01=testServer" >> $BASH_ENV
elif [ "$CIRCLE_BRANCH" == "prod" ]; then
echo "export APP_SERVER01=prodServer" >> $BASH_ENV
fi
- run:
name: Verify string interpolation etc
command: echo "Value of AppServer01 is $APP_SERVER01" # This prints correct value
- run:
name: Run pre-deploy
shell: powershell.exe
command: |
$App_Server01 = $env:APP_SERVER01;
Write-Host "App_Server01: $App_Server01, env:APP_SERVER01: $env:APP_SERVER01" # This prints empty values
([WMICLASS]"\\$App_Server01\ROOT\CIMV2:win32_process").Create("[path_to_script]");
Any help would be appreciated, Chat GPT has already given up, and as far as I can tell from the documentation this should work. Unless this specific case is not supprted for some reason…