4

I can query for all builds within a TeamProject as follows:

  var bServer = teamProjectCollection.GetService<IBuildServer>();
  IBuildDetail[] builds = bServer.QueryBuilds("myTeamProject");

This yields all builds within the given myTeamProject. But I am only interested in yesterday's builds.

I can obviously filter after I 've gotten the results within builds.
Still I am wondering if there exists an overload of QueryBuilds() to get builds within a provided timespan.


Background:
In my original TFS build solution, a custom code activity would get catch the BuildDetail properties that are important to us & would add them in an Excel sheet using Microsoft.Office.Interop.Excel.
This was rather convenient, since it took place during Build & our "BuildLog.xls" was always up-to-date.

Unfortunately this lead to this issue, so I had to remove the code activity & I am currently implementing Plan B: A console application scheduled to kick-in once a day, that queries for yesterday's builds & adds them in my Excel file.

Community
  • 1
  • 1
pantelif
  • 8,524
  • 2
  • 33
  • 48

1 Answers1

7

You can create an IBuildDetailSpec object and specify the MaxFinishTime (the end of the time range) and MinFinishTime (the beginning of the time range) to get builds in a range.

IBuildServer has a method to create IBuildDetailSpec and a QueryBuilds method to query with this spec.

Duat Le
  • 3,586
  • 2
  • 19
  • 18
  • Yes, this is what I needed - thank you very much. More useful info is also available here http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/68beb94c-f3a2-4303-9d5b-894c58be8258/ – pantelif Oct 27 '11 at 14:19