Triggering build using REST API and retrieve it's id

Hello,

I'm working on application which requires from me to trigger build outside of TeamCity and retrieve build id of this build to be able to track it's process. Is there any possibility to do this by REST API?

I'm currently using API methods from this article http://confluence.jetbrains.com/display/TCD6/Accessing+Server+by+HTTP . Unfortunately I'm not able to get build id using this methods...

3 comments
Comment actions Permalink

Hi Wojciech,

Unfortunately, build queuing is not yet part of "proper" REST API ( http://youtrack.jetbrains.com/issue/TW-14941 ) and the intended way to trigger a build in described by the link in the doc you mentioned.

As to retrieving build id in response - that is not that simple as there is no build id at the time of build queuing yet (it appears on the build start on agent).
I can only suggest to trigger a build with custom parameter of unique value and then check when build with the parameter is finished. Specifying custom parameter can have some side-effects, though (e.g. see http://youtrack.jetbrains.com/issue/TW-23700 ).

0
Comment actions Permalink

Hello, I'm trying to implement what you've suggested but I have some problems with triggering builds with custom parameters, and then find them via REST API.

To trigger new build I'm using this:

https://domain.com/httpAuth/action.html?add2Queue={buildType}&customParameter={customValue}

after triggering this build how should I ask via REST API to find this specific build status?

https://domain.com/httpAuth/app/rest/builds/?locator=running:any,buildType:{buildType},customParameter:{customValue}

raises error...

0
Comment actions Permalink

Hi,

REST API does not have a documented way to find build by it's properties (not sure where you derived "customParameter:{customValue}" from), so you will need to get the builds finished and check for their properties one by one.
You can also try "undocumented way" : add to the lcoator:
,property:(name:<name>,value:<value>)

But no guarantee as to how it will work...

0

Please sign in to leave a comment.