Accessing Environment Variables in Windows Executor on CircleCI


CircleCI users may encounter an issue where environment variables set in the Contexts section are not being correctly referenced in the Windows build. This can occur even when the variables appear correctly during the "Preparing environmental variables" step. This article provides a solution for referencing environment variables in a Windows executor environment.


  • A CircleCI project set up with a Windows executor.
  • Environment variables defined in the Contexts section of CircleCI.
  • A config.yml file that references these environment variables.


When using a Windows executor in CircleCI, the syntax for referencing environment variables differs from that used in Unix-based systems. In a Windows environment, which typically uses powershell.exe as the default shell, you should reference environment variables with the $env: prefix rather than the $ prefix used in Unix.

For example, if you have an environment variable named EULA_VERSION, you should reference it in your config.yml as follows:

- run: echo $env:EULA_VERSION

This syntax ensures that the environment variable is correctly interpolated during the build process on a Windows executor.


Additional Resources

For further details and community discussions around similar issues, you can explore the following resources: - CircleCI Discuss Forum - CircleCI Windows Executor Documentation - Using Environment Variables in CircleCI


Was this article helpful?
0 out of 0 found this helpful



Article is closed for comments.