Agile taught us to release early and release often, Agile also taught us to get the end user involved more frequently and directly. Goes without saying that release notes are an important part of any release. But what you don’t want to be doing is manually putting together the release notes with each frequent release you do. TFS lets you manage the application lifecycle with great ease & minimal administrative overhead, if your team is already checking in the code against work items and if you are using the TFS build infrastructure, good news is you already have all the raw material for your release notes stored in the TFS repository, in this blog post I’ll show you how to use the TFS API to generate the release notes from the Team builds.
So… How does it work?
- => Click connect to get all Build Definitions for a Team Project
- => Filter by excluding Disabled Build Definitions, or select the no.
- of builds to return per build definition, or exclude failed,
- partially successful, stopped and in progress builds.
- => Click ‘Generate Release Notes’ to generate the release
- notes, you can also export the results to PDF
Let’s get started, follow the steps below or download a working solution & an executable from here.
1. What you need…
To be able to extract the work item details from the build, you need to ensure,
- Developers check in code against work items – Download and Install TFS Power tools and enable check in policy to enforce check ins against work items.
- Enable the association of work items with change sets – If you are using the default template that ships with TFS 2010, edit the build definition and under the Process tab in the Advanced settings you will notice the option ‘Associate Change sets and Work Items’ set this to true.
2. TFS API – Programmatically get Work Items, Change sets, etc. from Team Builds
- 1. Let’s start by connecting to TFS programmatically using the API
<span style="color: blue"> private </span>
- 2. Get all Build Definitions for the selected Team Project programmatically
<span style="color: green"> </span><span style="color: blue">private </span><span style="color: #2b91af">IBuildDefinition</span> GetAllBuildDefinitionsFromTheTeamProject()
_bs = _tfs.GetService<<span style="color: #2b91af">IBuildServer</span>>();
<span style="color: blue">return </span>_bs.QueryBuildDefinitions(_selectedTeamProject);
- 3. Get All Builds in the build definition for specific build Definition specifications programmatically, this helps you narrow down the search and get the selected few filtered results, like in the snippet below, we specify the maximum number of builds to return, what build quality builds to return, etc.
<span style="color: green"> </span>
- 4. Get Associated Work Items for the selected build. You can also get the Associated Change sets, Build errors, Build Warnings, Work flow details, Changeset Ids, Configuration summaries, Opened work item ids, etc, check for more details for InformationNodeConverters. Notice in the snippet below that I am excluding a work item if it has already been added to the release notes as part of the previous selected build.
<span style="color: green"> </span>
Next… Create a Report using the Report Wizard and associate it to the Release Note Binding Source. Download a working solution and executable from here.
3. Review & Next Steps…
You can use the same logic with in a custom activity to churn out the release note details in the format you want in the build output, or use the code in a web application , host it in your network and easily let the team query the release notes as and when they need to, or host this in the cloud so the vendors outside the network can easily access the release notes as well, you could also convert this in to a VS extension, right click the build definition and you have the option to generate the release notes. You can also extend the logic further and include more functionality. Happy to hear your feedback! If you have any recommendations or questions, feel free to leave a comment. Thank you for taking the time out and reading this blog post. If you enjoyed the post, remember to subscribe to http://feeds.feedburner.com/TarunArora.
Check out the other posts on cool tools using TFS API.