How to read TeamCity build statistic in build steps?

We are using Teamcity to run Maestro automation tests. Maestro outputs a JUnit report after running tests, which we import using TeamCity XML Report Processing. We also send a slack notification using a command line build step, and want to include test count (passed/failed/total) in the message. Is there a way to read the test statistics from TeamCity inside a build step? Or perhaps in a Composite build that is dependent on the test build?



Perhaps using the REST API would be an option for you?

As an example, you could a call:


And the result would be something like this:

<build id="6536" number="1" status="SUCCESS">
<buildType id="XXXXXX" name="Dummy Build" projectName="PROJECT"/>
<property name="ArtifactsSize" value="24517"/>
<property name="BuildDuration" value="41728"/>
<property name="BuildDurationNetTime" value="768"/>
<property name="buildStageDuration:artifactsPublishing" value="508"/>
<property name="buildStageDuration:buildFinishing" value="8979"/>
<property name="buildStageDuration:buildStepsimpleRunner" value="768"/>
<property name="buildStageDuration:firstStepPreparation" value="405"/>
<property name="buildStageDuration:toolsUpdating" value="16"/>
<property name="BuildTestStatus" value="1"/>
<property name="queueWaitReason:Preparing_a_build_for_a_start_on_an_agent" value="50"/>
<property name="queueWaitReason:There_are_no_idle_compatible_agents_with_the_selected_cloud_image_which_can_run_this_build" value="32"/>
<property name="queueWaitReason:Waiting_for_starting_agent" value="1857"/>
<property name="queueWaitReason:Waiting_for_the_build_queue_distribution_process" value="15"/>
<property name="queueWaitReason:Waiting_to_start_checking_for_changes" value="136"/>
<property name="serverSideBuildFinishing" value="37"/>
<property name="SuccessRate" value="1"/>
<property name="TimeSpentInQueue" value="2093"/>




Hi, thanks for sharing this! We could try to implement this as a pull model.
But isn't it possible to read build statistics in a build step? It would help us implement a push model, where we can send the data at end of build, rather than a pull model which would have to continuously poll TC.


As far as I am aware, using the REST API would be the recommended way to do this. 


Please sign in to leave a comment.