0

I have a Python script that has url, token, location, and version as environment variables. I trigger it using the classic Python task. I declared these variables inside the pipeline variables section, and inside the code, I did the following:

import os

os.environ['url']
os.environ['token']

but I get keyerror: 'url'

I came across this link, which creates a variable group and passes the environment variables as arguments. But this step follows inline script based execution.

Task classic python

The variables url and token are marked as secret for the purpose of sharing them here.

Pipeline Variables

  • Please post the pipeline snippet. How are you setting these env variables? – Jay May 15 '23 at 22:45
  • the env varibales are defined in the variables section under pipeline variables, attached the image to question for your reference – mannar-senpai May 16 '23 at 06:20

1 Answers1

0

To access pipeline variables from Release pipeline into classic task, we can import them by passing them as arguments.

In .py script

import sys

url = sys.argv[1]
token = sys.argv[2]

print(url, token)

in arguments we pass the following $(URL) and $(TOKEN) without spaces.