I thought the variables set in the Variables tab in a release pipeline were set as environment variables? On my TestCase Project I've got some settings stored as environment variables which are accessed during setup process of my tests, but in azure release pipeline it just comes back as null(this is using a hosted agent).
How can I access the Variables set in Variables tab of a release pipeline from my C# code?
My code to access Environment variables at the moment is
Environment.GetEnvironmentVariable("DevOpsUserName", EnvironmentVariableTarget.Machine)
This doesn't pull back the variables data.
Add the environment variable in the DevOps Pipeline In Azure DevOps, go to the “pipelines” and then go to the “library”. Add a variable group if there isn't one. And then add the variable “key/name” and the “value” to the variables section of the group and click on “save”.
You define and manage these variables in the Variables tab in a release pipeline. In the Pipeline Variables page, open the Scope drop-down list and select "Release". By default, when you add a variable, it is set to Release scope. Share values across all of the tasks within one specific stage by using stage variables.
You can list the variables in a variable group with the az pipelines variable-group variable list command. If the Azure DevOps extension for CLI is new to you, see Get started with Azure DevOps CLI.
They are set as environment variables (excepting secret variables, which are not automatically converted to environment variables for security reasons).
However, they're not machine-level environment variables. They are process-level.
Use EnvironmentVariableTarget.Process
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With