3

Using TeamCity 8.0.4 (build 27616)

I use a call to my TeamCity server to get a list of broken builds:

http://teamcity.exactbid.net/guestAuth/app/rest/builds/?locator=status:failure,sinceBuild:(status:success)

If I a project is in the failure state, that API call returns count =1 and the details of the broken project.

The problem is if that project has a currently running build, the API call returns count 0 and no projects in the broken list.

As soon as the project build finished (and breaks again) the count goes back to 1.

So hopefully there is something in my locator query that I can change to get broken builds even if they are currently building.

The TC ui seems to know about it because the parent projects of my broken project all show red. Just not sure how to get it right in the API query.

slolife
  • 19,520
  • 20
  • 78
  • 121

2 Answers2

3

Try adding running:any. Maybe running defaults to false, although I can't find that in the documentation.

shoover
  • 3,071
  • 1
  • 29
  • 40
2

Here's how to display a list of failed builds:

http://teamcity.exactbid.net/guestAuth/app/rest/builds/?locator=status:failure

Failed builds are builds that have already finished and failed, what I think you are looking for is a way of showing builds that are running and failing:

http://teamcity.exactbid.net/guestAuth/app/rest/builds/?locator=status:error,status:running

This looks for builds that are running and contain errors (which cause the build to fail, unless explicitly told not to)

You may have to use two REST API calls to get the builds:

  1. that are finished and failed
  2. that are running and failing
ShaneC
  • 2,237
  • 2
  • 32
  • 53
  • you are correct in pointing out that I am not looking for all of the past broken builds. Maybe I should reword my question words to state that I am looking to get a list of projects `that have the last completed build that broke`. So if ProjectA's last completed build broke, but it has a build running, I still want ProjectA to be listed. I think you're right that I might need to do two or more REST calls to calculate this information. – slolife Feb 11 '14 at 17:34
  • Might want to change the title of the question to get better answers. Here's some pseudo code to tide you over though: Loop through each build configuration on your TC server; Check the last build's status; Save a list of failed build; Display the failed builds – ShaneC Feb 12 '14 at 11:42
  • 1
    One note: to do a status locator with multiple values, use the format `?locator=status:(error,running)` – Mike Post Feb 12 '16 at 04:23