Getting elapsed build time from REST API
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?
Please sign in to leave a comment.
Hello,
running-info is only present for running builds. Please add running:true or running:any flag. For example:
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.
Hi Robert,
Sorry, I misunderstand you question at first. I updated my response above, please review it.
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.