How to get the running build status of a build using TeamCity API

Hi,

I am using the TeamCity Rest API to get list of builds and all the information. The scenario is when user does "Run" in Teamcity i want to insert the current Build values and UnitTest and codecoverage results into my database. the issue which i am facing is TeamCity API is giving me the last build details and not the current build details.
Is there any way i can add my parsing solution as exe and execute it once the build is completed in TeamCity.
Please help me out on this as how to acheive this.

Regards,
Sajesh Nambiar

8 comments
Comment actions Permalink

Please suggest me some options

0
Comment actions Permalink

Hi,

To get the status of running build please try the following request: http://teamcityserver:8111/guestAuth/app/rest/builds?locator=running:true

0
Comment actions Permalink

Thanks i am able to fetch the BuildStatus using the link which you have provided but I am not able to fetch the test results and coverage results using statistics.
If you could help me to get this for the running build i ll be really thankful to you.

0
Comment actions Permalink

To list all build's tests: GET http://teamcity:8111/app/rest/testOccurrences?locator=build:<build locator>
Coverage results are stored as build artifacts, so you can download them using request: http://teamcity:8111/httpAuth/app/rest/builds/<buildLocator>/artifacts/content/<artifact relative name>
For more details please see REST API section in documentation.

0
Comment actions Permalink

Thanks, but will this give the test and code coverage results of running build which has not completed yet.

0
Comment actions Permalink

Build artifacts can also be uploaded to the server while the build is still running. To instruct TeamCity to upload the artifacts, the build script should be modified to send service messages. Also you can use TeamCity meta-runner.

0
Comment actions Permalink

I published the artifacts but still using Meta-runner i could see the complete xml is getting updated once the build is completed, so its the same thing i am getting old build details using REST API.
I was thinking of build chain, Step1) Build will be executed.
Step2) Custom code to invoke the build,test and code coverage details will be invoked and inserted into Database(In this case i will get current build details using TeamCity Rest API).

Let me know if this approach is fine or can you suggest some other options.

I am completely stuck on this.

Thanks.
Sajesh

0
Comment actions Permalink

Yes, I would recommend to split the build in two build steps, as you described.

0

Please sign in to leave a comment.