我可以从 msbuild 脚本取消 TeamCity 构建吗?

发布于 2024-10-01 22:10:43 字数 877 浏览 0 评论 0原文

TeamCity 允许我使用 ##teamcity 交互从 MsBuild 脚本返回报告。我可以用它来告诉 TeamCity 构建失败,或者确实成功,但我想告诉它取消构建。有谁知道有什么方法可以做到这一点?

我可以用它来通知 TeamCity 失败...

<Message Text="##teamcity[buildStatus status='FAILURE']" Condition="Something==SomeCondition" />

我很乐意这样做...

<Message Text="##teamcity[buildStatus status='CANCEL']" Condition="Something==SomeCondition" />

我已经尝试过 TeamCity 服务任务,但到目前为止还没有。

编辑:

所以看来这个功能不可用,尽管 解决方法http请求可用于取消构建。还有一个用于取消构建 TC 网站的功能请求

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?

I can use this to inform TeamCity of failure...

<Message Text="##teamcity[buildStatus status='FAILURE']" Condition="Something==SomeCondition" />

I would love to do this...

<Message Text="##teamcity[buildStatus status='CANCEL']" Condition="Something==SomeCondition" />

I've tried out the TeamCity Service Tasks but nothing thus far.

EDIT:

So it seems this feature is not available, although a workaround http request can be used to cancel a build. There is also a feature request for Cancelling a build the TC website.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

为你拒绝所有暧昧 2024-10-08 22:10:43

根据 JetBrains 问题跟踪器发布页面,自 TeamCity 2019.1 EAP 1可以通过服务消息停止构建,如下所示:

##teamcity[buildStop comment='canceling comment' readdToQueue='true']

According to JetBrains issue tracker and release page, since TeamCity 2019.1 EAP 1 builds can be stopped with service message as in:

##teamcity[buildStop comment='canceling comment' readdToQueue='true']
云柯 2024-10-08 22:10:43

您可以使用自 最初发布以来已更改的未记录的 http 请求< /a>.您现在需要“operationKind=1”。我使用了像这样的powershell运行器:

$buildId = %teamcity.build.id%
$uri = "http://teamcity/ajax.html?guest=1&comment=Cancelling+build+for+some+reason&submit=Stop&buildId=$buildId&kill&operationKind=1"
$response = Invoke-WebRequest -UseBasicParsing -Uri $uri

另一个SO帖子可以告诉你如何制作一个来自 MSBuild 的 http 请求

“guest=1”表示我正在使用访客帐户,对于要取消的项目,它至少需要“停止构建/从队列中删除”。

You can use the undocumented http request which has changed since it was originally posted. You now need "operationKind=1". I used a powershell runner like so:

$buildId = %teamcity.build.id%
$uri = "http://teamcity/ajax.html?guest=1&comment=Cancelling+build+for+some+reason&submit=Stop&buildId=$buildId&kill&operationKind=1"
$response = Invoke-WebRequest -UseBasicParsing -Uri $uri

Another SO post can tell you how to make an http request from MSBuild

The "guest=1" means I'm using the guest account, which at minimum needs the "Stop build / remove from queue" for the project you're going to cancel.

π浅易 2024-10-08 22:10:43

从 Teamcity 8.1(来源)开始,可以取消构建通过 REST API。

摘自 9.x 文档,取消当前运行构建

curl -v -u user:password --request POST "http://teamcity:8111/app/rest/builds/<buildLocator>" --data "<buildCancelRequest comment='' readdIntoQueue='false' />" --header "Content-Type: application/xml"

Since Teamcity 8.1 (Source) it is possible to Cancel the Build via REST API.

Taken from the 9.x Documentation, cancelling a currently running build

curl -v -u user:password --request POST "http://teamcity:8111/app/rest/builds/<buildLocator>" --data "<buildCancelRequest comment='' readdIntoQueue='false' />" --header "Content-Type: application/xml"
秋日私语 2024-10-08 22:10:43

您不能只使用错误任务吗,这应该会导致执行构建停止。

Can you not just use the Error task, this should cause the execution of the build to stop.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文