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.
Just specify the reference name in the blank of task, and then, you can call this output variable abc by using the format: <reference name>. <variable name> . For example, if you specify the reference name as mycustom , just call the output variable by using $(mycustom. abc) .
We could write it out to a json/xml file via power shell task, and publish the file as artifacts. Then read in that file via PowerShell in your release definition. Also, we could pass the variable from build to release via the extension Variable Tools for Azure DevOps Services.
An output variable is a specific kind of pipeline variable that is created by a task. The deployment task assigns a value to a variable which then makes it available to use across a pipeline.
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))
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