Showing posts with label XAMLBuild. Show all posts
Showing posts with label XAMLBuild. Show all posts

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.


Saturday, April 2, 2016

TFS Build Issue: - Builds will be in queued state forever and will not build unless the priority of build is manually set to above normal i.e High or Above Normal.

Hi All,
I want to share my experience in fixing one of the build issue stated above.
TFS Build Issue: - Builds will be in queued state forever and will not build unless the priority of build is manually set to above normal i.e High or Above Normal.

Recently one of our customer started facing issue that the Continuous Integration (CI) build queued forever and was able to build the application only my manually setting the priority of the queued build to High or Above normal. Since this required manual intervention and customer was quite upset that they have to set priority of the build to “High or Above normal” for all CI builds.
When we connected to the customer and checked there were no issues in build server as there were enough Build controller and available agents to handle build requests. We also checked restarting the build service, but it did not resolve the issue.
As we already observed, since build works fine when the priority of the build is changed, we suspected that there may be some old builds which may be in queued state and TFS is waiting for those builds to get completed first.
So to clarify the above doubt we executed below query against the “Tfs_<Collection_Name>” database to know what is the build queue state
select * from tbl_buildQueue
Surprisingly we found that there were many builds in State = 2 i.e. “In progress” or “Queued” State but there were no builds existing for those Build definitions for that Team Projects under that collection, and this was the actual cause of the issue, since TFS still thinks that there are builds yet to be completed and all new builds are set in queued state and build remains in this state forever since there is no way to complete the previous builds as the Build Definitions or Builds would have been deleted.
We can also execute below query to get the build status along with the Build Definition Name
select a.DefinitionId,a.Status,b.DefinitionName from tbl_buildQueue a inner join tbl_BuildDefinition b on a.DefinitionId=b.DefinitionId
To solve this, we executed below query which will change the state of all build runs into completed State i.e. to 16
update tbl_BuildQueue set status=16 
Post to this change CI build started working as expected J 

Hope this post helped.