How to include Branches in app/rest/projects API call?

We are building a little app to display build status for our TeamCity Server.  We are breaking it down by Project > BuildConfig > Branch and displaying the latest build per branch.

I am able to grab the build list easy enough, and am able to grab the Projects and include the BuildConfigs at the same time.

Builds:

/app/rest/builds?&fields=$long,build($short,testOccurrences,statusText($long),buildType,startDate,finishDate,triggered($long),changes($short,change($short,comment)))

Projects/BuildConfigs:

app/rest/projects?&fields=$long,project($long,vcsRoots($long,vcs-root($long,properties($long))))


I cannot figure out a way to include the branches in that url, so I am having to call:

app/rest/buildTypes/id:<BuildConfigID>/branches


to get a list of the branches, which means a hit on the server for every BuildConfig which seems excessive.

Any idea how to get the Branches included in the projects url, or is there a way to get all Branches for each config in one url call?

Thanks for any advice in advance.

Cheers,
Mike

1 comment
Comment actions Permalink

Hi Mike,

It is not possible to include branches in /rest/projects call. You can use the following request to get the list of "N" builds on all branches in all build configurations in a project:
http://localhost:8111/app/rest/buildTypes?locator=affectedProject:(id:<projectId>)&fields=buildType(id,name,builds($locator(running:false,canceled:false,count:<N>,branch:unspecified:any),build(number,status,statusText)))

or in all projects:
http://localhost:8111/app/rest/buildTypes?&fields=buildType(id,name,project,builds($locator(running:false,canceled:false,count:<N>,branch:unspecified:any),build(number,status,statusText)))


For more details see the related comment.
However it is not possible to show one latest build in all build configurations per branch.
0

Please sign in to leave a comment.