Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass Azure devops release pipeline(Classic editor) output variable to multiple jobs in same stage or to multiple stages outside

I am using the release pipeline classic editor and have a requirement of passing an output variable generated in a task to multiple jobs in the same stage or to outside stages. Currently, this output variable is available only inside the same job and I have to write the same task in multiple jobs and stages and I feel it is a redundancy. Is there any way to implement it?.

like image 871
mystack Avatar asked Nov 01 '25 11:11

mystack


1 Answers

In the Classic editor, I am afraid that output variables in a different job is not feasible. Please refer to this document .

enter image description here

As a workaround , you can use variables across jobs and stages via variable groups.

First define the variable in the variable group, then update the variable group through rest api or azure cli, and replace the defined variable with the value of the variable generated by the task.

PUT https://dev.azure.com/{organization}/{project}/_apis/distributedtask/variablegroups/{groupId}?api-version=5.1-preview.1

Here is a case about update variable group with powershell script.

Another workaround : You can share values across all of the stages by using release pipeline variables. The solution is updating the Release Definition for the Release Pipeline variable in the Stage where the variable is set.

  • Define a variable in the release definition Variable.
  • Use REST API Definitions - Update to update the value of the release definition variable in the agent job.
  • Use the updated value of the release definition variable in the next agent job.

The details info about using REST API to update the value of the release definition variable, you can follow this ticket.

For detailed steps and guide, please refer to this blog .

like image 82
Hugh Lin Avatar answered Nov 04 '25 09:11

Hugh Lin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!