4
votes

We have one build pipeline (Product1) that use multiple branches (dev, test, prod).

In release pipeline/artifacts settings, we use the following settings:

  • Default version: Latest from a specific branch with tags
  • Branch: $(Branch.name) --> this is settable at release time.

The scenario that we are having:

  • The latest successful build is using the dev branch.
  • There is another successful build using the test branch.
  • Create new release, and set Branch.name to test --> it does not use test branch, it uses the last successful one which is dev branch.

How can we use branch variables in release pipelines?

1
Is this for a Git repo or a TFVC repo? The answer to your question is different depending on which you're using.Daniel Mann
we are using bitbucketMohamed Shehata

1 Answers

2
votes

As you set the Default version: Latest from a specific branch with tags.

You need to add tags for builds, then specify the specific tag in artifacts settings, otherwise it will use the last successful builds generated from the build pipeline (will ignore the specified branch).

For example, in below screenshot I added a tag master for the successful build using the master branch, then specify the tag in Artifact settings. Thus when you create a release it will automatically select the latest build which has the tag master and using master branch.

enter image description here