Add branch name to build number in Azure DevOps

TLDR; I have created an Azure DevOps extension which will append the branch name to all builds not created from the master branch. You can get it on the Visual Studio marketplace.

Azure DevOps is our go to source control, build, release and work item management software. We've used (and still like) many others, but at the moment Azure DevOps works well for our projects.

I'll always setup a release pipeline that automatically builds and releases from the master branch, and may automatically trigger a build and release on another branch for example develop. In this case you may only want develop builds to go to one environment.

You can also trigger a build for any branch manually, this may not always be a good idea depending on your setup, but if it's not going to do any harm, you may want to build from a branch you are working on and release to an environment or create nuget packages before you merge into a shared branch.

Azure DevOps will show you the branch a build came from in many places, but I find it useful to have it in the version number aswell. If a build was from the master branch then nothing is added to the version number, if it came from any other branch the branch name is appended to show this is a pre-release build.

This version number is then easy to see at a glance throughout Azure DevOps and can help avoid the wrong build being used.

I've created an Azure DevOps extension that you can use to do this, which is available now on the Visual Studio Marketplace.

Give it a go, and let us know what you think on Twitter or in the comments below!

  • Post