Wednesday, July 6, 2016

TFS 2013 Team Build : Part 2 - How to change the default build number format of a build definition.

How to change the default build number format of a build definition to give meaningful names to the completed builds.
Hi All,
In this post we will see how we can change the Build Number format to give meaningful names to the completed builds. By default the build number format of the build is: $(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)

SampleCI_20160706.1
Example: If my build definition name is SampleCI then the build number will be:
  •         SampleCI_20160706.1
  •         SampleCI_20160706.2
  •         SampleCI_20160706.3

To change this to some other format, we have to go to any of the build definition we have created or new. In the Build Definition go to BuildNumberFormat process parameter in “Process Tab”.
Our goal is to change the build number format as shown below, we want to capture the team project name also in the build number. $(TeamProject)_$(BuildDefinitionName)_$(Date:yyMMdd)$(Rev:.r) let’s see how to do this.


Step 1. Create a new Build Definition or open existing build definition, then click on Process tab.

Step 2. Under Process tab, look for Build Number Format process parameter and click on the ellipses button as shown in below screenshot.


Step 3. In the BuildNumber Format Editor window, you can see default build number format string and its preview. To see and add the other tokens click on Macros >> button.


Step 4. On clicking Macros >> button, you can see all available list of tokens and its values as shown in below screenshot



Step 5. Since we wants to add the $(TeamProject) token before $(BuildDefinitionName), place the cursor at the starting point i.e. before $(BuildDefinitionName), tag as shown below. Then select the $(TeamProject) token and click on Insert button.



Step 6. On clicking Insert button, we will see that the token is been added to the format string and we can modify the string by adding a underscore symbol (_) to differentiate between Team project name and build definition name as shown below. Click Ok button


Step 7. That’s all, we are done with setting the build number format to
$(TeamProject)_$(BuildDefinitionName)_$(Date:yyMMdd)$(Rev:.r)
We can see the format in the build process parameter value as below.



Step 8. Save the changes to the build definition and queue the build.


In the My Builds dropdown list of Team Explorer builds page we can see that build number also includes Team Project name , here in my case Team project name is FabrikamFiber and build definition name is DemoApp


Below screenshot shows the Team Project Name in build summary report




Hope you enjoyed this blog. Let me know for any queries.


No comments:
Write comments