How to access environment variables in Windows Runners on Bitbucket cloud pipelines?
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
Unlike Linux runners, It is not possible to access the value of the variables in the pipelines using "$" with Windows Runners.
Cause
Windows Runners run directly on Powershell. Therefore it uses a different syntax for referencing variables.
Solution
For example, to access the value of the repository variable "test_value" in the pipeline windows runner, you may use $env:test_value. The sample Bitbucket YAML configuration is given below:
pipelines:
default:
- step:
runs-on:
- self.hosted
- windows
script:
- echo "This step will run on a self-hosted windows runner.";
- Write-Output $env:test_value