Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Teamcity API, Status of build configurations in a project

Tags:

rest

teamcity

I am trying to find if there is any API method or call by which i can get the status of latest build configuration, for example latest build is still running, has been queued is successful.

I was able to get only the last successful build details but not the status of the build.

http://<TeamcityServer>/httpAuth/app/rest/builds/buildType:(id:BUILDTYPE),status:SUCCESS
like image 425
Sudheej Avatar asked Jun 26 '17 14:06

Sudheej


1 Answers

In order to know if the build is queued, running, or finished, you should get the value of the state and not the status.

http://<TeamcityServer>/httpAuth/app/rest/builds/?locator=buildType:<BuildType>,state:any,branch:default:any,count:15

buildType: The name given at your configuration, prefixed by the project.

state: Possibles values are: pending, queued, running.

branch: If your branch configuration may run on multiple branches, you may want to specify this. Otherway, only the default branch would be on the results.

count: arbitrary limit set here.

A result would be:

<builds count="5" href="/guestAuth/app/rest/builds/?locator=buildType:A_B,state:any,branch:default:any,count:5" nextHref="/guestAuth/app/rest/builds/?locator=buildType:A_B,state:any,branch:(default:any),count:5,start:5">
    <build id="3767209" buildTypeId="A_B" state="queued" branchName="refs/heads/master" defaultBranch="true" href="/guestAuth/app/rest/buildQueue/id:3767209" webUrl="http://<TeamCityServer>/viewQueued.html?itemId=3767209"/>
    <build id="3767307" buildTypeId="A_B" state="queued" branchName="5566" href="/guestAuth/app/rest/buildQueue/id:3767307" webUrl="http://<TeamCityServer>/viewQueued.html?itemId=3767307"/>
    <build id="3767394" buildTypeId="A_B" state="queued" branchName="5558" href="/guestAuth/app/rest/buildQueue/id:3767394" webUrl="http://<TeamCityServer>/viewQueued.html?itemId=3767394"/>
    <build id="3767425" buildTypeId="A_B" state="queued" branchName="5563" href="/guestAuth/app/rest/buildQueue/id:3767425" webUrl="http://<TeamCityServer>/viewQueued.html?itemId=3767425"/>
    <build id="3766826" buildTypeId="A_B" number="7398" status="SUCCESS" state="running" running="true" percentageComplete="42" branchName="5570" href="/guestAuth/app/rest/builds/id:3766826" webUrl="http://<TeamCityServer>/viewLog.html?buildId=3766826&buildTypeId=A_B"/>
</builds>
like image 171
Didier Aupest Avatar answered Nov 10 '22 18:11

Didier Aupest