0
votes

I am using Build Pipeline: VSTS and Repo: VSTS

I am trying to create VSTS build pipelines for two branches Dev and UAT. I can achieve it by creating two different pipelines but since both has almost similar steps so I wanted to have only one pipeline and depending on condition I can omit some steps. But I am not able to figure out how to pass the variable value(branch which triggered the build) before queueing the build in VSTS.

Background: I tried to get both branch source, setted triggers on both branch and use Build.SourceBranchName variable but it is giving value the top level(Project) value instead of branch name. I have structure like below

Project - Dev - QA

The agenda is to trigger the build pipeline on checkin, sanity checks an publish the artifacts as per the environment(Dev,QA). I am not going for CD right now (will be handled manually because of some constraints).

The solution might sound very awkward but I am a newbie and I want to learn it.

I have checked some people have explained through API but any way to do through UI?

VSTS use API to set build parameters at queue time

Any help would be highly appreciated. enter image description hereenter image description here

1
try investigating the Variables Tab. It is between the Tasks and Triggers Tab. - Kirsten Greed
Build.SourceBranchName should works. Are "Dev" and "QA" branches in your repo? Or they are just folders? - Eddie Chen - MSFT
Dev & QA are branches in my repo under Yomail folder - Saurabh Bhasin
Did you add the mapping for these two branches under "Get Sources" settings? - Eddie Chen - MSFT
Yes, in the first snapshot I have shown the same. - Saurabh Bhasin

1 Answers

0
votes

To add a variable that you can pass the value when you queue the build you need to go to variables tab, then add your variable and check the checkbox Settable at queue time.

enter image description here

Now when will queue a build you can change the default value. enter image description here