Mateen-Hussain
Mateen-Hussain

Reputation: 748

History of test results team city

I'm looking to get a history of test runs from teamcity by calling the rest apis.

So far I found:

 http://teamcity.xyz.com/app/rest/builds/65602/statistics

But this will give only stats for one run.

I found below from Teamcity api documentation, but it is not clear where I should enter the multiple build numbers

  http://teamcity:8111/httpAuth/app/rest/builds?locator=BUILDS_LOCATOR&fields=build(id,number,status,buildType(id,name,projectName),statistics(property(name,value)))

has anyone tried this before??

Upvotes: 1

Views: 1224

Answers (1)

Matt
Matt

Reputation: 3704

You can achieve this through a different avenue by using the buildTypes endpoint because the locator only supports a single id dimension.

e.g.

/httpAuth/app/rest/buildTypes/id:##BUILD_TYPE##/builds?fields=build(id,number,status,buildType(id,name,projectName),statistics(property(name,value)))

This will return data similar to the following

<builds>
  <build id="185" number="1.0.0.2" status="SUCCESS">
    <buildType id="Website_1BuildApplication" name="1 - Build Application" projectName="Website"/>
    <statistics>
      <property name="ArtifactsSize" value="4201093"/>
      <property name="BuildArtifactsPublishingTime" value="921"/>
      <property name="BuildCheckoutTime" value="377"/>
      <property name="BuildDuration" value="21791"/>
      <property name="BuildDurationNetTime" value="20493"/>
      <property name="buildStageDuration:artifactsPublishing" value="952"/>
      <property name="buildStageDuration:buildFinishing" value="15"/>
      <property name="buildStageDuration:buildStepRUNNER_6" value="19313"/>
      <property name="buildStageDuration:firstStepPreparation" value="219"/>
      <property name="buildStageDuration:sourcesUpdate" value="496"/>
      <property name="BuildTestStatus" value="1"/>
      <property name="SuccessRate" value="1"/>
      <property name="TimeSpentInQueue" value="6272"/>
    </statistics>
  </build>
  <build id="183" number="1.0.0.1" status="SUCCESS">
    <buildType id="Website_1BuildApplication" name="1 - Build Application" projectName="Website"/>
     <statistics>
       <property name="ArtifactsSize" value="4200811"/>
       <property name="BuildArtifactsPublishingTime" value="297"/>
       <property name="BuildCheckoutTime" value="19500"/>
       <property name="BuildDuration" value="45123"/>
       <property name="BuildDurationNetTime" value="25326"/>
       <property name="buildStageDuration:artifactsPublishing" value="328"/>
       <property name="buildStageDuration:buildFinishing" value="140"/>
       <property name="buildStageDuration:buildStepRUNNER_6" value="23603"/>
       <property name="buildStageDuration:firstStepPreparation" value="265"/>
       <property name="buildStageDuration:sourcesUpdate" value="19516"/>
       <property name="BuildTestStatus" value="1"/>
       <property name="SuccessRate" value="1"/>
       <property name="TimeSpentInQueue" value="234"/>
     </statistics>
   </build>
</builds>

Hope this helps

Upvotes: 1

Related Questions