简体   繁体   中英

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. The endpoint:

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

Shows the last 50 builds.

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.

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:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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