2013-04-05 64 views
3

是否可以通过REST API取消当前正在运行的构建?通过REST调用停止TeamCity构建

我有一个集成,它获取当前正在运行的构建,并且如果它们失败,我想终止给定类型的构建。我知道如何列出给定类型的失败构建,然后如何通过停止命令?

回答

3

也许无法与REST API,但如果你看看here(朝向注释部分的底部)有一个“无证”功能,让你做到这一点通过HTTP。

2

您可以使用自it was originally posted以来更改过的未记录的http请求。您现在需要“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 

“客人= 1”表示我使用来宾帐户,其在最低限度需要“停止建立/从队列中删除”为项目你要取消。

“comment = ...”可以设置为描述您取消的原因。

0

由于TeamCity的8.1,可以使用REST API停止编译:

curl -v -u user:password --request POST "http://localhost:7000/app/rest/buildQueue/<buildLocator>" --data "<buildCancelRequest comment='' readdIntoQueue='true' />" --header "Content-Type: application/xml" 
相关问题