c# - Fetching build definitions from Visual Studio Online through TFS API -


i'm having problem retrieving build information visual studio online project through tfs api. can connect project, seems, , find expected team project collection , team project, despite project having 2 build definitions , number of builds, tfs api returns zero-length arrays me when querying build definitions or builds. project git project. production code similar test code i've written attempt debug problem:

var tfsuri = new uri("https://[my project].visualstudio.com"); var tcs = new tfsconfigurationserver(tfsuri);  var teamprojcollections = tcs     .catalognode     .querychildren(         new[] { catalogresourcetypes.projectcollection },         false,         catalogqueryoptions.none)     .select(collectionnode => new guid(collectionnode.resource.properties["instanceid"]))     .select(collectionid => tcs.getteamprojectcollection(collectionid));  var tpc = teamprojcollections     .single(x => x.name == @"[my project].visualstudio.com\defaultcollection");  var newteamprojects = tpc     .catalognode     .querychildren(         new[] { catalogresourcetypes.teamproject },         false,         catalogqueryoptions.none);  var tp = newteamprojects     .single(x => x.resource.displayname == "[team project name]");  var buildserver = tpc.getservice<ibuildserver>(); var builddefinitions = buildserver.querybuilddefinitions(tp.resource.displayname); 

builddefinitions empty array. build definitions definitely there - can connect project visual studio, , displays them in builds tab of team explorer. code has worked me in past, tfvc projects connecting to, not git project. interestingly, if use versioncontrolserver team project collection, this:

var vcs = tpc.getservice<versioncontrolserver>(); var teamprojects = vcs.getallteamprojects(true); 

..teamprojects zero-length array.

also, if try builds team project collection specifying general build detail spec, no builds returned.

some additional information: i'm using vs enterprise 2015 rc. i'm administrator of vso project, , created team project collection, team project, , build definitions. i've pushed code, , run builds. i'm logged in myself when connecting through api. credentials appear correct.

so, in trying figure out, have questions. need different approach accessing git repository? perhaps it's possible through new tfs 2015 rest apis? perhaps need make builds "visible" myself in vso project?

you can utilize buildhttpclient make similar requests 2.0 rest api.

this sample on github pretty resource, if rather poll single project should more this:

using system; using system.collections.generic; using microsoft.teamfoundation.build.webapi; using microsoft.visualstudio.services.client;  static void getbuildstatus() {     var tfsurl = "http://<tfs url>:<port>/tfs/<collectionname>";     var buildclient = new buildhttpclient(new uri(tfsurl), new vssaadcredential());     var definitions = buildclient.getdefinitionsasync(project: "<projectmame>");     var builds = buildclient.getbuildsasync("<projectname>";      foreach (var build in builds.result)     {         console.writeline(string.format("{0} - {1} - {2} - {3}", build.definition.name, build.id.tostring(), build.status.tostring(), build.starttime.tostring()));     } } 

Comments