Getting elapsed build time from REST API

Answered

Hi

I'm working on a project that needs to get the time a build took to complete (including tests) from the TeamCity REST API.

Unfortunately given I need to specify the different fields I'm requesting, I can't work out which field I can use to get the elapsed build time in seconds. I've seen references to "elapsedSeconds" in places, but have had no luck.

At the moment my request looks like: http://teamcity/app/rest/builds?locator=buildType:(id:my_id_goes_here)&fields=count,build(buildTypeId,finishDate,status,statusText,webUrl)

I think getting the elapsed seconds would look something like: http://teamcity/app/rest/builds?locator=buildType:(id:my_id_goes_here)&fields=count,build(buildTypeId,finishDate,status,statusText,webUrl,running-info(elapsedSeconds))

The request above succeeds, but the responses I get don't include the elapsed seconds.

Can somebody point me in the right direction? And is there a listing of the different fields available in the REST API for different types of objects?

0
3 comments

Hello,

running-info is only present for running builds. Please add running:true or running:any flag. For example:

http://teamcity/app/rest/builds?locator=buildType:(id:<buildConf_ID>),running:any&fields=count,build(buildTypeId,finishDate,status,running-info(elapsedSeconds))

Unfortunately we do not have full REST API documentation, please vote for https://youtrack.jetbrains.com/issue/TW-34689. As of now you can use General Usage Principles to explore the API.

0

Hi Robert,

Sorry, I misunderstand you question at first. I updated my response above, please review it.

0
Avatar
Permanently deleted user

Hi Alina,

Thanks for directing me to that issue! - I've voted on it.

I've just realised this is much simpler than I thought - one of the fields I can request is "startDate", so I can just calculate the delta from that.

0

Please sign in to leave a comment.