【问题标题】:TeamCity: How to get a list of last builds for each build configuration that are currently not running?TeamCity:如何获取当前未运行的每个构建配置的最后构建列表?
【发布时间】:2013-03-06 17:43:42
【问题描述】:

我正在使用 TeamCity 7.1。我想获取一个列表,其中包括当前未运行的每个构建配置(构建类型)的最后构建。我发现了这个问题:TeamCity - How do you get a list of the last finished build of each project through rest api? 但答案中的 REST URI 对我不起作用。

<teamcity-server>/httpAuth/app/rest/builds?locator=sinceBuild:(status:failure) 

似乎有效,并为我提供了之前失败后成功的所有构建。

相反

<teamcity-server>/httpAuth/app/rest/builds?locator=sinceBuild:(status:success)

不返回任何构建。

我知道我可以获取所有构建类型,遍历它们并获取最新完成的构建使用

<teamcity-server>/httpAuth/app/rest/buildTypes/id:<build-type-id>/builds/running:false?count=1&start=0 

("count=1&start=0" 可能不是必须的) 但我不确定我得到的是否真的是最新版本。这也需要对所有构建类型进行多次 REST 调用。一个简洁的解决方案将只使用一个 REST 调用。

有什么想法吗?

【问题讨论】:

  • 我试过了,&lt;teamcity-server&gt;/httpAuth/app/rest/builds?locator=sinceBuild:(status:failure)&lt;teamcity-server&gt;/httpAuth/app/rest/builds?locator=sinceBuild:(status:success) 都在工作。第二个可能不适合您,因为在最后一次成功构建之后您可能没有任何构建。然后它将返回 0 个计数。总的来说,它们中的任何一个都会给你一个 0 计数,因为你的最后一次构建要么是成功,要么是失败。

标签: api rest teamcity


【解决方案1】:

根据TeamCity REST API documentation from JetBrains,可以通过以下任一方式定位构建:

<teamcity-server>/httpAuth/app/rest/buildTypes/id:<build-type-id>/builds/running:false,status:success

<teamcity-server>/httpAuth/app/rest/builds/running:false,status:success

如果您尝试在 buildType 和 &lt;buildTypeLocator&gt; can be id:&lt;btXXX_internal_buildConfiguration_id&gt; or name:&lt;Build_Configuration_name&gt; 下查询某些内容,则必须按照当前的 REST API 将 buildType 加上 &lt;buildTypeLocator&gt; 后缀(引用自文档)。因此,您必须指定构建 id 或构建名称。

但是,您所期望的理想方式是:

<teamcity-server>/httpAuth/app/rest/buildTypes/builds/running:false,status:success

我想你可以在TeamCity Support 提出这个问题。

【讨论】:

  • 这不会得到最后完成的构建,而是 all 构建。
猜你喜欢
  • 2020-06-15
  • 1970-01-01
  • 2014-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多