How to access environment variables in Windows Runners on Bitbucket cloud pipelines?
Platform Notice: Cloud Only - This article only 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:
1
2
3
4
5
6
7
8
9
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
Updated on April 8, 2025
Was this helpful?
Still need help?
The Atlassian Community is here for you.