1
votes

I have 2 build pipelines in my azure devops project, one for building source code and the other one is for making the setup. I want the build number generated by the first pipeline that compiles code to be passed to the next pipeline which creates the setup file because i want the setup file to take the same version, so I added a variable group with a variable called sharedBuildCounter.

But when I set sharedBuildCounter the build number in the first pipeline using logging command like this(used inside PowerShell task):

Write-Host "##vso[task.setvariable variable=variable_name;]new_value"

The variable indeed takes the new value and I am able to output the new value using another PowerShell task with one line:

Write-Host $(SharedBuildCounter)

And when I run the next pipeline that builds the setup, I find that sharedBuildCounter is being re-set to the default empty value.

Notice: I found threads that suggests using API rest calls to change variable values, but it don't seem to include a specific pipeline name in case of using pipeline variables(not variable groups).

1

1 Answers

1
votes

Variable groups will help to share static values across builds and releases pipeline.

What you need is a way to pass variables from one pipeline to another. I'm afraid to say the is no official way to do this.

As a workaround you could update the value of your variables inside your variable group. There are multiple ways to handle this, Rest API, powershell, 3rd-party extension. Detail ways please refer answers in this question: How to Increase/Update Variable Group value using Azure Devops Build Definition?

If you want to get the value of variable in the pipeline. Since you have used logging command to update that variable.

You need to use Rest API to get that particular build log to fetch related info.