Skip to content

Instantly share code, notes, and snippets.

@robertmuehsig
Created August 12, 2013 19:05
Show Gist options
  • Save robertmuehsig/6213991 to your computer and use it in GitHub Desktop.
Save robertmuehsig/6213991 to your computer and use it in GitHub Desktop.
TFS API with GIT returns only Team Foundation based Projects
class Program
{
static void Main(string[] args)
{
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("https://code-inside.visualstudio.com/DefaultCollection"));
var vcs = tfs.GetService<VersionControlServer>();
var teamProjects = vcs.GetAllTeamProjects(true);
var oneoffixxProject = teamProjects.Where(x => x.Name == "DrinkHub").Single();
IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer));
var builds = buildServer.QueryBuilds(oneoffixxProject.Name);
foreach (IBuildDetail build in builds)
{
var result = string.Format("Build {0}/{3} {4} - current status {1} - as of {2}",
build.BuildDefinition.Name,
build.Status.ToString(),
build.FinishTime,
build.LabelName,
Environment.NewLine);
System.Console.WriteLine(result);
}
Console.ReadLine();
}
}
@LGfSQazW
Copy link

LGfSQazW commented Jun 1, 2016

@lafritay, how would you use this to get information such as build status? I was able to get a list of git projects but haven't figured out how to use this to query the builds or other info. Can't seem to find much on Google. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment