-1

Lately I've been requested to run a python script on my Azure Release Pipeline.

This script needs some environment variables for being executed, as I've seen that in the build pipeline, the task include a "env" part where I can set environment variables. The thing is that in the release pipeline I cannot find anything related to env

Azure Release Pipeline Python task

I've researching in all the documentation and previous questions but I cannot find anything else related with this. Is there any way to set environment variables here?

The only I need is that the variables declared on the variable group linked to the pipeline can be readed and used in the python script.

Thank you!

Paul
  • 31
  • 1
  • 8

2 Answers2

0

You could not define Environment Variables directly in Python Script task in Azure Release Pipeline.

As a work around, you could use Arguments to define Variables used in this task.

Here is a sample:

1.Link your Python Script task to the Target Variable Group. enter image description here

2.Add arguments to link to variables enter image description here enter image description here

RoyWang-MSFT
  • 245
  • 1
  • 3
0

In release pipelines you should have a variables option at the top. Click this and under Pipeline Variables you'll see two columns name and value. Enter the variables here then you can access them using os in python with the following:

import os
os.environ['name']
DavidCox88
  • 813
  • 1
  • 10