VSTS Release Management: filter by branch on artifact source
Asked Answered
S

2

13

I am using VSTS build to run a CI build. This build definition is the same for all my git branches (master, develop, features, etc).

I am now trying to implement a deployment pipeline using VSTS release management. I plan to have two distinct release definitions. One for feature branches and one for the more important branches like develop and master. The release definition for feature branches would be more lightweight.

I think this is pretty basic and usual. In fact, that's pretty much what is documented in Microsoft's typical use case for Release Management.

For both of these pipelines, I want to configure them to start automatically using the 'Continuous Deployment' trigger. When I select this trigger, I must select an artifact source.

Unfortunately, an artifact source takes all artifacts (regardless of the branch) coming from a given build definition (my CI build). Since I use the same CI build definition for all my branches, it looks like I can't configure my two release pipelines in 'Continuous Deployment' and still use the same build definition as an artifact source.

Anybody knows how to share the same build definition for multiple release definitions but only start a release for a specific branch? Anybody knows of a way to filter by branch when we define an artifact source?

Satellite answered 13/4, 2016 at 11:9 Comment(2)
I'm in a similar predicament, except it's the build triggered by the creation of a pull request. It's triggering a release and it shouldn't. The PR builds are done in a separate branch (e.g. refs/pull/16/merge). I too would like to filter the release trigger by branch so it's only triggered by master being built.Grata
Your scenario is even more problematic than the one I described! I suggest that you either file it on the Visual Studio UserVoice or up vote and comment my entry available here.Satellite
C
5

Configure branch specific release deployment

  1. Go to release management in VSTS
  2. Go to the definition of the release
  3. Go to tab triggers
  4. Add Continuous Deployment trigger
  5. Here you can select a specific branch (for branch)

Release trigger definition

Availability of feature

  • This feature is available in VSTS
  • In the TFS on-premise version it was supposed to be available in version Server 2017.1 but it is still not available in version 2018.1
Cabalist answered 2/12, 2016 at 8:49 Comment(3)
Be adviced that the branch filter setting only is available when the source code relies within a VSTS/TFS repository. When using external sources like github the branch filter is not shown/available.Androus
I'm using 2017.2 and this feature still does not seem to be present. Unless it's Git-onlyBorman
still not there :(Dendritic
M
3

Currently there is no way in VSTS Release Management to do conditional deployment based on branch.

An alternate would be to create separate BDs for different branches and then configure them as artifact sources for the RDs.

This will also give users a clarity about the artifact from its name itself.

Morpheme answered 13/4, 2016 at 12:6 Comment(3)
That's a shame. Since in Git branches are created and deleted very often, we have only one build definition. This avoids back and forth between dev team and devops team that setup the build definitions. By having a single BD for all branches, the devops is not involved at all when branches are created / deleted.Satellite
Yeah but people mostly release from a fixed branch like master or release in which devs merge there changes. So the main branches don't get deleted. So it makes sense to have a different build definition for a different branch. You should raise a User Voice for this. May be there are others who want this same functionality. If you can share your scenario, I can think of a workaround.Morpheme
Creating multiple BDs just for this is redundant and wasteful (time-wise), in my opinion. In my case (see my comment above), it won't help. Configuring a branch policy to do a build for a PR, you can then require another build after the master branch is updated, but you don't get to specify a different BD. I want a release triggered off the master build, not the PR build.Grata

© 2022 - 2024 — McMap. All rights reserved.