How to pass variable from build to release in azure build to release pipeline
R

1

10

How to pass variable from build to release in azure build to release pipeline: We have variable in CI pipeline --> we have to pass that variable in Release pipeline--> that variable has to set in another yaml file. is this possible?

Remand answered 3/5, 2020 at 15:27 Comment(0)
E
3

For now, we could only set a variable in a variable group as a static value and use it in both build and release.

Detail ways please refer Marina's answer in this question: VSTS : Can I access the Build variables from Release definition?

But according to your description, what you want is to set the variable during the build and then use it in the release pipeline.

The is no official way to pass variables follow this. As a workaround, you could use some 3rd-partly extension, store the values in a file (json, xml, yaml, what have you) and attach that as a Build Artifact. That way you can read the file in the release and set the variable again.

Take a look at this similar issue: How to get the variable value in TFS/AzureDevOps from Build to Release Pipeline?

Erickericka answered 4/5, 2020 at 3:32 Comment(4)
Thanks for your answer, i have one more question, As u mentioned store the values in json or xml, is there any reference link ??Remand
@krishna Thanks for the update. You could refer the code of this task in GitHub: github.com/nkdAgility/azure-devops-variable-toolsErickericka
Hi patrick, as a note they mentioned it only works for powershell taks not for bash, so is there any alternative choice. See the prob is we are setting variable as sname=TEST_Name echo "##vso[task.setvariable variable=outputName;isOutput=true]$sname" so i want outputName to be passed in release variable section and from that variable i have yaml file which is taken as artifacts in CI pipeline and some of the variables are replace in yaml file, so want outputName to be set in release variable section and to be replace in yaml file. please help me broRemand
Hi @krishna Afraid what you are looking for is not available right now. A workaround which may be helpful, using multiple jobs (build job, release job) in a single yaml file. Then it's able to pass variables between build jobs. For example, set an output variable from job A and map the variable into job B. Details please refer official tutorial here: learn.microsoft.com/en-us/azure/devops/pipelines/process/…Erickericka

© 2022 - 2024 — McMap. All rights reserved.