9. May 2017
Automation , VSTS
For most cases triggering a release based on finished builds on a specific branch from your repo is sufficient. But what if you'd like to have a little more control over what is released depending on some specific conditions? Well you could create different build definitions, specify different triggers on so on. In this post I'll present you a little feature, which you could find helpful in some specific scenarios.
Each finished build in VSTS can be marked with a custom tag, which will help to categorize it. You can even think about building a "tag pipe" like this:
which would help you to decided what to do depending on at which step your build failed.
Finished build with a "Tag_ToBuild" tag attached.
There's one issue with tags however - you have to add them manually. What if you'd like to automate things?
Adding a build tag
Some time ago the team responsible for VSTS introduced a new command, which can be used to add a build tag directly from a build. To use it you can do following:
- add a new Powershell build step to your build definition
- paste following command: Write-Host "##vso[build.addbuildtag]your_tag"
With this simple script each finished build will have your_tag attached to it. At first glance it doesn't look very impressively, but when you consider passing a variable or using output from the previous steps, it becomes much more powerful.
Triggering a release
So far so good - we now how to automate tags so it's possible to incorporate them in our releases. To do so go to your release definition and then click on the "Triggers" tab.
"Triggers" tab with a tag added to constrain CD a little
Along with artifact source and branch triggers triggers you have an option to add tags, which will be used to check whether a release should be triggered. Now each time a build finishes, a release won't triggered unless specific tag was provided.