Search code examples
restteamcity

TeamCity - how to get currently running builds via REST API?


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)?


Solution

  • 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.