Toni Miguel López
Toni Miguel López

Reputation: 352

Is it possible to read or save in a variable the data returned by an Azure Pipelines script?

I have an Azure Devops Pipeline that has a task script like that:

steps:
  - script: python settings.py

This script "returns" (internally makes a print('...')) a value I'd like to save during the pipeline for later use, but I can't find a way to do it.

I've tried logging, but I don't think it's possible:

steps:
  - script: echo '##vso[task.setvariable variable=version]'${python settings.py}

Is it possible in any way or is there none to be able to do this?

Thanks.

Upvotes: 7

Views: 2137

Answers (1)

R Jain
R Jain

Reputation: 598

You can add this code in the python script to save the value for later use in the pipeline. The idea is output this to the console and VSTS will automatically save it under the variable - version.

print('##vso[task.setvariable variable=version;]%s' % (version))

Upvotes: 12

Related Questions