TeamCity - 如何通过 REST API 获取当前正在运行的版本?
有谁知道如何使用 TeamCity REST API 来找出当前正在运行哪些构建以及它们的运行时间(已用时间与估计时间)?
Does anyone know how to use the TeamCity REST API to find out which builds are currently running, and how far through they are (elapsed time vs estimated time)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
该 URL 返回您所要求的内容,包括完成百分比。
http://teamcityserver/httpAuth/app/rest/builds?locator=running:true
来源:http://devnet.jetbrains.net/message/5291132#5291132。
REST API 文档 上的相关行是“http://teamcity: 8111/httpAuth/app/rest/builds/?locator= - 通过“构建定位器”获取构建。在“用法”部分。
这适用于 TeamCity 版本 6.5;我还没有在早期版本上尝试过,但我怀疑它可以回到版本 5。
The URL returns what you are asking for, including percentage complete.
http://teamcityserver/httpAuth/app/rest/builds?locator=running:true
Source: http://devnet.jetbrains.net/message/5291132#5291132.
The relevant line on the REST API documentation is the one that reads "http://teamcity:8111/httpAuth/app/rest/builds/?locator= - to get builds by "build locator"." in the "Usage" section.
This works with TeamCity version 6.5; I haven't tried it on earlier versions, but I suspect it will work back to version 5.
您可以使用“running:true/false/any”作为构建定位器的构建维度之一。 (编辑:在 TeamCity 6.0 中添加)
http://confluence.jetbrains.net/display /TW/REST+API+Plugin
TeamCity REST API 文档将为您提供一些构造 URL 的方法的示例。该页面上的“构建定位器”部分将列出用于优化结果的不同选项(其中之一正在运行)。
但是,我不知道如何使用 REST API 获取有关正在运行的构建已用时间/估计时间的信息。我不确定这是否可能。如果您确实找到了一种方法来做到这一点,我将非常有兴趣阅读如何实现!
祝你好运!
You can use "running:true/false/any" as one of the build dimensions for the build locator. (EDIT: added in TeamCity 6.0)
http://confluence.jetbrains.net/display/TW/REST+API+Plugin
The TeamCity REST API documentation will give you some examples of some of the ways you can construct the URL. The Build Locator section on that page will list the different options you have for refining your results (one of which is running).
However, I don't know of a way to get information about the running builds elapsed/estimated time using the REST API. I'm not sure if this would be possible. If you did find a way to do this, I would be be very interested to read how!
Good luck!
我知道你的问题已有五年多了,但你想要
接受的答案中建议的方法 只提供了
percentageComplete
属性,如果不再次调用 API,该属性就没那么有用。可以通过提供字段请求来实现url 的参数,例如:
其中
{buildFields}
是builds
对象的属性。为此,我使用:完整的 url is then
返回类似的内容
,该内容将为您提供
running-info
元素中的完成百分比和已用/估计总时间。注意:我使用的是 TeamCity 9;字段请求参数似乎存在在文档中TeamCity 5.x-7.x 但输出可能不太一样。
I realise your question is more than five years old, but you wanted
The method as suggested in the accepted answer only gives the
percentageComplete
attribute, which is not as useful without having to make another call to the API.It can be achieved by supplying the fields request parameter to the url, e.g.:
where
{buildFields}
are properties of thebuilds
object. For this, I am using:The full url is then
which returns something like
which will give you the percentage complete and elapsed/estimated total times in the
running-info
element.Note: I am using TeamCity 9; the fields request parameter appears to be present in the documentation for TeamCity 5.x-7.x but the output may not be quite the same.
我做了一些挖掘,JetBrain 网站上的一篇文章声明支持运行: true 实际上是为 TC6 添加的。 TeamCity 5.X REST 文档 只是链接到另一个页面,但不指定 TC5 中支持的内容以及 TC6 中的新增内容。
编辑:嘿马特,我发布了一个问题,询问特定于 TC 5.X 的 REST 文档。我知道,如果我知道对于我正在使用的 TeamCity 版本,我到底可以使用 REST 做什么,将会非常方便,并且您可能也会感兴趣!
I did a little digging and a post on JetBrain's site stating that support for the running:true was actually added for TC6. TeamCity 5.X REST documentation just links to a different page which doesn't specify what was supported in TC5 and what is new to TC6.
EDIT: Hey Matt, I posted a question inquiring about REST documentation specific to TC 5.X. I know it would be very handy for me to know what exactly what I can do with REST for the version of TeamCity I am using and thought it may interest you as well!
你有一个变体使用而不是api -
[http://teamcity/ajax.html?getRunningBuilds=1]
所以这不是一个好的变体,但对我来说它非常好!
You have a variant use not api -
[http://teamcity/ajax.html?getRunningBuilds=1]
So it's not good variant, but for me it's very good!