Created
August 12, 2013 19:05
-
-
Save robertmuehsig/6213991 to your computer and use it in GitHub Desktop.
TFS API with GIT returns only Team Foundation based Projects
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
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(); | |
} | |
} |
Thanks!
@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
The VersionControlServer object will only tell you about and let you interact with TFVC projects. If you want to list all of the team projects in a team project collection, you should do this:
ICommonStructureService css = tfs.GetService();
css.ListAllProjects();
Thanks,
Taylor
TFS Version Control Team