Created
January 29, 2014 19:02
-
-
Save cyberzed/8694590 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var serverUri = new Uri(@"http://foo:8080/tfs/"); | |
using( var collection = new TfsTeamProjectCollection( serverUri, CredentialCache.DefaultCredentials ) ) | |
{ | |
var server = collection.GetService<ICommonStructureService>(); | |
var projects = server.ListProjects(); | |
var homeProject = (from p in projects | |
where | |
p.Name.Equals("projectFoo", StringComparison.CurrentCultureIgnoreCase) | |
select p).Single(); | |
var buildServer = collection.GetService<IBuildServer>(); | |
var buildDefinitions = buildServer.QueryBuildDefinitions( homeProject.Name ); | |
var selectedBuildDefinitions = (from bd in buildDefinitions | |
where | |
bd.QueueStatus == DefinitionQueueStatus.Enabled && | |
bd.Name.Contains("Bar") | |
select bd); | |
var builds = new List<IBuildDetail>(); | |
foreach (var buildDefinition in selectedBuildDefinitions) | |
{ | |
builds.AddRange(buildServer.QueryBuilds(buildDefinition)); | |
} | |
var buildList = (from b in builds | |
let Duration = b.FinishTime!=DateTime.MinValue ? b.FinishTime-b.StartTime : DateTime.Now-b.StartTime | |
orderby b.StartTime descending | |
select new { | |
BuildDefinitionId = b.BuildDefinition.Id, | |
BuildDefinitionName = b.BuildDefinition.Name, | |
b.StartTime, | |
Duration, | |
b.RequestedFor, | |
b.Status, | |
b.CompilationStatus, | |
b.TestStatus, | |
b.BuildNumber, | |
b.SourceGetVersion | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment