4

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?.

1 Answer 1

6

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 .

1
  • I am using a different method with PAT token, from the CI build i am triggering the release with updated variable.
    – mystack
    Jun 2, 2020 at 11:38

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.