简体   繁体   English

如何通过 Travis API 列出给定项目的所有构建?

[英]How to list all builds of a given project through Travis API?

The Travis documentation is not clear if we can navigate through the builds. Travis 文档不清楚我们是否可以浏览构建。 The endpoint:终点:

https://api.travis-ci.org/repos/caelum/vraptor4/builds https://api.travis-ci.org/repos/caelum/vraptor4/builds

Shows the last 50 builds.显示最近 50 个构建。

But how to get the whole history?但是如何获得整个历史?

Builds are paginated, so you need to fetch with multiple requests.构建是分页的,因此您需要使用多个请求来获取。

The endpoint supports the after_number parameter, which is the build number (field number ) from the last build in the previously fetched page.端点支持after_number参数,它是先前获取的页面中最后一个构建的构建编号(字段number )。

So if your first result set's last build entry has the build number 2669 (which is the current last build number on the page from https://api.travis-ci.org/repos/caelum/vraptor4/builds ), you'd fetch subsequent builds with this URL:因此,如果您的第一个结果集的最后一个构建条目的构建号为 2669(这是https://api.travis-ci.org/repos/caelum/vraptor4/builds页面上当前的最后一个构建号),您将使用此 URL 获取后续构建:

https://api.travis-ci.org/repos/caelum/vraptor4/builds?after_number=2669

That way you iterate through the builds rather than fetch thousands of them at once.这样您就可以遍历构建而不是一次获取数千个构建。

For API V3, we should use offset instead, see https://developer.travis-ci.com/pagination对于 API V3,我们应该使用offset ,请参阅https://developer.travis-ci.com/pagination

For example, https://api.travis-ci.org/repo/expertiza%2Fexpertiza/builds?limit=5&offset=5例如https://api.travis-ci.org/repo/expertiza%2Fexpertiza/builds?limit=5&offset=5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM