Forum Discussion
Access pipeline variables in Azure Release for classic python task
To access pipeline variables within a classic Python task in Azure DevOps, you can use the `system` prefix to access the variable. Here's how you can modify your code to retrieve the values of your pipeline variables:
import os
url = os.environ['SYSTEM_URL']
token = os.environ['SYSTEM_TOKEN']
location = os.environ['SYSTEM_LOCATION']
version = os.environ['SYSTEM_VERSION']
In Azure DevOps, pipeline variables are available as environment variables prefixed with `SYSTEM_`. By using the `SYSTEM_` prefix followed by the variable name, you can access the values of pipeline variables within your Python script.
Make sure that the pipeline variables are properly defined and accessible within the pipeline context. Double-check the variable names and ensure they are correctly defined in the pipeline variables section.
By accessing the pipeline variables with the `SYSTEM_` prefix in your Python script, you should be able to retrieve the values without encountering the `KeyError`.
If I have answered your question, please mark your post as Solved If you like my response, please give it a like |
Deleted
Thanks for the answer but I still couldn't access the variables I get the same key error
this is pipeline variable is have defined, marked URL and token as secret just to share it here