TC Rest API retreving specific data

Answered

The url below is the call I am currently using which retrives everything that I want but takes a good amount of time to retrieve. I would like to cut down the time for retrieval by being more specific on what I pull but have not had any success with the following items.

app/rest/builds/?sinceDate=20160501T010101%2B1000&count=2000&fields=build(id,number,status,agent,startDate,finishDate,buildType(name,projectName),statistics(property(name,value)))

1. I would like to pull only builds with a status of success which I have been able to do but not while maintaining  the sinceDate filter. So far I can either gather with a sinceDate filter or a status=Success but not both. I was wondering if there is a way to have both since I have tried many different variations to have both with nothing working correctly.

2. All of the data I am pulling by the url is useful except for some of the statistics values which I would like to narrow down if it would help load time. I've been fiddling with this one also but have not been able to narrow down which build statistics I pull. I specifically would like just BuildDuration, TimePentInQueue, and BuildCheckoutTime.

One of my attempts to limit what statistics are pulled which did not work out below.

 app/rest/builds/?sinceDate=20160501T010101%2B1000&count=2000&fields=build(id,number,agent,startDate,finishDate,buildType(name,projectName),statistics(property(name:BuildDuration)))

3.. Currently I am pulling all builds regardless of project can I somehow list projects that I do not want builds for. (this would be helpful but not nearly as much as the other two)

Being able to do any of these would be helpful but the first two more so. Thanks

 

4 comments

Hello Anthony,

Please find the answers below:

  1. To get successful builds since some date use the following request:
    /app/rest/builds/?locator=sinceDate:20160501T010101%2B1000,status:success
  2.  It's not possible to filter out some statistics properties. Actually the request time depends on number of the fields specified. Filtering by some statistics value most probably won't help.
  3. To filter by project use the following request:
    /app/rest/builds/?locator=sinceDate:20160501T010101%2B1000,status:success,project:<projectID>

 

1

Thanks for the quick reply being able to filter by date and if it was successful will be very helpful.

0

I want to retrieve the number of builds executed in a specific month.

For eg- i want to know the number of builds executed between 1st april to 1st May.

How can i do that?

Teamcity has sincedate api but that does not solve the purpose.

0

Hi Abhishek,

 

the build locator accepts a wide array of parameters. While sinceDate is a very specific one, there is some more flexible ones that should allow you to get what you want: https://www.jetbrains.com/help/teamcity/rest-api.html#RESTAPI-BuildLocator

 

In particular, startDate and finishDate (with the "before" and "after" parameters for them) will give you the flexibility to get a month of builds.

0

Please sign in to leave a comment.