Can I cancel a TeamCity build from my msbuild script?

TeamCity allows me to report back from my MsBuild script using the ##teamcity interaction. I can use this to tell TeamCity that the build has FAILED, or indeed SUCCEEDED, however I would like to tell it to CANCEL the build instead. Does anyone know of a way to do this?

At the moment I'm telling my build to fail, but I would like the same behaviour in TC as when the 'Cancel' button is clicked (e.g the build marked as cancelled, hidden from view (unless option to show is enabled) and the last build that either passed or failed is displayed).


Comment actions Permalink


So far there is no ability to mark the build as canceled from within a build.
Please vote/comment on the feature request. It also has a link to a workaround solution for now (call to HTTP request to make the build stop as if called from web UI).

Comment actions Permalink

Thankyou Yegor,

As you mentioned in your feature request, syntax like <Message Text="##teamcity[buildStatus status='CANCEL']" Condition="Something==SomeCondition" /> would fit in nicely with the current buildstatus commands. I will try and use the http request - I hope the 2 votes so far for this change will help get it included in future TC builds :)



Please sign in to leave a comment.