Buildkite API的Python包装器
pybuildkite的Python项目详细描述
PyBuildkite
一个Python库和Buildkite API的客户机。在
使用
要获取包,请执行:
pip install pybuildkite
然后设置Buildkite对象的实例,设置访问令牌,并发出任何可用的请求。在
^{pr2}$分页
Buildkite为返回大量数据的端点提供分页。默认情况下,此包装器返回100
对象。但是,任何可能包含更多内容的请求都提供了分页选项。在
当with_pagination=True
时,我们返回一个response对象,该对象的属性可能具有next_page
、last_page
、previous_page
或{
builds_response=buildkite.builds().list_all(page=1,with_pagination=True)# Keep looping until next_page is not populatedwhilebuilds_response.next_page:builds_response=buildkite.builds().list_all(page=builds_response.next_page,with_pagination=True)
文物
工件可以作为二进制数据下载。将以下工件加载到内存中 Python bytes 然后将它们写入光盘:
artifacts=buildkite.artifacts()artifact=artifacts.download_artifact("org_slug","pipe_slug","build_no",123,"artifact")withopen('artifact.bin','b')asf:f.write(artifact)
大型工件应流化为字节块,以限制内存消耗:
stream=artifacts.download_artifact("org_slug","pipe_slug","build_no",123,"artifact",as_stream=True)withopen('artifact.bin','b')asf:forchunkinstream:f.write(chunk)
unicode文本工件可以很容易地转换为字符串:
text=str(artifact)
许可证
此库是在许可文件中的BSD样式许可下分发的。在
- 项目
标签: