开发者

Fail build via REST API with TeamCity, from another build config, after build is already finished

I have some integration tests that get kicked off by TeamCity on a successful build. I have had success using the TeamCity REST API in order to tag the build as passed or failed, but would actually like to mark the build status as passed or failed (in the same way builds are failed due to compilation or unit test failures).

The documentation for the REST API is pretty sparse. Is it just not possible to do this through the REST API or is it undocumented?

Clarification:

Current process is as follows:

"App" TC Build configuration actually builds the application and runs the unit tests.

"Test" TC Build configuration depends on "App" configuration completing successfully. If "App" builds successfully (no compile or unit test failures), "Test" configuration kicks off, which pulls down the build artifacts and runs the live integration tests on the application. Prior to these tests being run, "App" configuration has a status of passing, since it compiled successfully and there were no unit test failures.

What I am trying to do is to change "App" config status to failed, if the "Test" configuration failed. Currently I am me开发者_如何学Pythonrely tagging "App" as passed or failed, but the actual build status is always passing. Essentially I am trying to get the change log or history to show the red X icon for a failed build, rather than the green check mark.

"App" and "Test" are 2 separate TeamCity build configurations. Since they are separate, Build Script Interaction, as suggested by @sharma, will not do the trick, since Build Script Interaction can be used to fail/update the currently running build configuration, whereas I am trying to update/fail a separate and already completed build configuration.

Why do we have 2 separate configs and not just run the tests from the main build? Speed of course! The integration tests take up to 10 minutes to run, and we don't want to slow down the compile cycle just because the integration tests are running.


Actually you can change build status even after build finished with the following non-documented request (you need buildId of build you want to change):

curl -v --request POST "http://your-teamcity-url/ajax.html" -u login:password --data "comment=Your reason to fail build" --data "status=FAILURE" --data "changeBuildStatus=buildId"


You should be able to do it through build Interaction scripts.

UPDATE: Look here, It should have "reporting messages for build logs". If you have following message printed to console in which ever application build you are running. The teamcity build will fail and show as error. If you change status to Failure it will still fail. You have more information on the link I provided. An example message you may want to printout:

  "##teamcity[message text='Exception text' errorDetails='stack trace' status='ERROR']"

Look at this


So the answer to my original question, is it possible to use REST API to mark build as failed from another build configuration, is that it is not possible.

Per TeamCity support: There is no way to change a build status after it has been finished. This is not a limitation of REST API, this is just not implemented feature of TeamCity. Here is a related feature request in our tracker: http://youtrack.jetbrains.net/issue/TW-2529

(I upvoted @sharma's answer and comments, as they were definitely informative, but ultimately not a solution to my problem.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜