Does anyone know how to use the TeamCity REST API to find out which builds are currently running, and how far through they are (elapsed time vs estimated time)?
Ta Matt
TeamCity REST API It allows accessing resources via URL paths. You can start working with the REST API by opening the http://<TeamCity Server host>:<port>/app/rest/server URL in your browser: this page gives several pointers to explore the API. To learn more, proceed to the dedicated TeamCity REST API Help.
BuildLocator Last modified: 26 July 2022. Represents a locator string for filtering Build entities. Examples: id:1 — find build with ID 1 .
To stop a running build:Click Stop build link, which becomes available, while the build is in progress. In the Stop build dialog, enter your comment, and click OK.
You can use "running:true/false/any" as one of the build dimensions for the build locator. (EDIT: added in TeamCity 6.0)
http://confluence.jetbrains.net/display/TW/REST+API+Plugin
The TeamCity REST API documentation will give you some examples of some of the ways you can construct the URL. The Build Locator section on that page will list the different options you have for refining your results (one of which is running).
However, I don't know of a way to get information about the running builds elapsed/estimated time using the REST API. I'm not sure if this would be possible. If you did find a way to do this, I would be be very interested to read how!
Good luck!
The URL returns what you are asking for, including percentage complete. http://teamcityserver/httpAuth/app/rest/builds?locator=running:true
<builds count="1">
<build id="10" number="8" running="true" percentageComplete="24" status="SUCCESS" buildTypeId="bt3" startDate="20110714T210916+1200" href="/httpAuth/app/rest/builds/id:10" webUrl="http://phillipn02:29000/viewLog.html?buildId=10&buildTypeId=bt3"/>
</builds>
Source: http://devnet.jetbrains.net/message/5291132#5291132. The relevant line on the REST API documentation is the one that reads "http://teamcity:8111/httpAuth/app/rest/builds/?locator= - to get builds by "build locator"." in the "Usage" section.
This works with TeamCity version 6.5; I haven't tried it on earlier versions, but I suspect it will work back to version 5.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With