Skip to main content

PyBuildkite

Build status Coverage Status PyPI most recent version PyPI downloads

A Python library and client for the Buildkite API.

Usage

To get the package, execute:

pip install pybuildkite

Then set up an instance of the Buildkite object, set you access token, and make any available requests.

from pybuildkite.buildkite import Buildkite, BuildState

buildkite = Buildkite()
buildkite.set_access_token('YOUR_API_ACCESS_TOKEN_HERE')

# Get all info about particular org
org = buildkite.organizations().get_org('my-org')

# Get all running and scheduled builds for a particular pipeline
builds = buildkite.builds().list_all_for_pipeline('my-org', 'my-pipeline', states=[BuildState.RUNNING, BuildState.SCHEDULED])

# Create a build
buildkite.builds().create_build('my-org', 'my-pipeline', 'COMMITSHA', 'master', 
clean_checkout=True, message="My First Build!")

Per-Page Configuration

The per_page parameter controls the number of items returned per API request. This can be useful for organizations with large datasets that experience timeouts.

# Default behavior (100 items per page)
buildkite = Buildkite()

# Custom per_page for smaller responses (useful for large organizations)
buildkite = Buildkite(per_page=25)

Pagination

Buildkite offers pagination for endpoints that return a lot of data. By default this wrapper returns 100 objects per page. However, any request that may contain more than that offers a pagination option.

When with_pagination=True, we return a response object with properties that may have next_page, last_page, previous_page, or first_page depending on what page you're on.

builds_response = buildkite.builds().list_all(page=1, with_pagination=True)

# Keep looping until next_page is not populated
while builds_response.next_page:
    builds_response = buildkite.builds().list_all(page=builds_response.next_page, with_pagination=True)

Artifacts

Artifacts can be downloaded as binary data. The following example loads the artifact into memory as Python bytes and then writes them to disc:

artifacts = buildkite.artifacts()
artifact = artifacts.download_artifact("org_slug", "pipe_slug", "build_no", 123, "artifact")
with open('artifact.bin', 'b') as f:
  f.write(artifact)

Large artifacts should be streamed as chunks of bytes to limit the memory consumption:

stream = artifacts.download_artifact("org_slug", "pipe_slug", "build_no", 123, "artifact", as_stream=True)
with open('artifact.bin', 'b') as f:
  for chunk in stream:
    f.write(chunk)

A unicode text artifact can be turned into a string easily:

text = str(artifact)

License

This library is distributed under the BSD-style license found in the LICENSE file.

Metadata

Release files for pybuildkite 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybuildkite 1.3.0
File Size Uploaded
pybuildkite-1.3.0.tar.gz 21.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pybuildkite 1.3.0
File Interpreter ABI Platform
pybuildkite-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 40.4 kB

Release files / pybuildkite-1.3.0.tar.gz

Download URL pybuildkite-1.3.0.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
81e5531b74ca21ccb85159e5d757b9153c062b1bf583118b0bc8bef314228f1c
BLAKE2b-256 checksum
How to use checksums
fef6f4870301b9d398e7850631bd3b364e22f0558e7e85138cb80f224128b1c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / pybuildkite-1.3.0-py3-none-any.whl

Download URL pybuildkite-1.3.0-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fbfc7700377b8478c92b89711ff974a5bcf44fc93bd8d3d4d17b88da3f6e70d8
BLAKE2b-256 checksum
How to use checksums
17675783801c84f2030b26fbaac3f367038e85664a7edd4f3bb5644fb3e35676
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

1 release file

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page