Question

I created a spec to query for a project name and possibly a specific date, but looks like the query fields don't have an option to do this. Here is what I have. Is there a way I can get builds for a project and a specific day instead of iterating through all builds?

var buildDetailSpec = buildServer.CreateBuildDetailSpec(project.Name, "*");
buildDetailSpec.InformationTypes = null;
//buildDetailSpec.MaxFinishTime = dateToGet;

IBuildDetail[] builds = buildServer.QueryBuilds(buildDetailSpec).Builds;

The only option I see get all builds with maxfinishtime and iterate through each of them to check for their finishdate. Is there a better way?

Was it helpful?

Solution

The CreateBuildDetailsSpec method has an overloaded method that takes in TeamProject as a parameter. See this

To search for a particulra date, set the MinFinishTime and MaxFinishTime properties of buildDetailsSpec object. Something like below (assuming that dateToGet has the 00:00:00 hours)

var buildDetailSpec = buildServer.CreateBuildDetailSpec(project.Name);
buildDetailSpec.InformationTypes = null;
buildDetailSpec.MaxFinishTime = dateToGet; /*at 00:00:00*/
buildDetailSpec.MaxFinishTime = dateToGet.AddDays(1).AddMinutes(-1); /*at 23:59:59*/

IBuildDetail[] builds = buildServer.QueryBuilds(buildDetailSpec).Builds;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top