pybuildkite


Namepybuildkite JSON
Version 1.2.3 PyPI version JSON
download
home_pagehttps://github.com/pyasi/pybuildkite
SummaryPython wrapper for the Buildkite API
upload_time2023-06-16 13:44:21
maintainer
docs_urlNone
authorPeter Yasi
requires_python
license
keywords buildkite continuous integration api ci wrapper python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyBuildkite

[![Build status](https://badge.buildkite.com/89bf10df4492f2f2d61ca707078828824fec3b08cb85192e6d.svg)](https://buildkite.com/pybuildkite/pybuildkite)
[![Coverage Status](https://coveralls.io/repos/github/pyasi/pybuildkite/badge.svg?branch=master)](https://coveralls.io/github/pyasi/pybuildkite?branch=master)
[![PyPI most recent version](https://badge.fury.io/py/pybuildkite.svg)](https://pypi.org/project/pybuildkite/)
[![PyPI downloads](https://img.shields.io/pypi/dm/pybuildkite.svg)](https://pypi.org/project/pybuildkite/)

A [Python](https://www.python.org/) library and client for the [Buildkite API](https://buildkite.com/docs/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.

```python
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!")
```

## Pagination

Buildkite offers pagination for endpoints that return a lot of data. By default this wrapper return `100` objects. 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.

```python
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](https://docs.python.org/3/library/stdtypes.html#binary-sequence-types-bytes-bytearray-memoryview)
and then writes them to disc:

```python
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:
```python
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:
```python
text = str(artifact)
```

## License

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



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pyasi/pybuildkite",
    "name": "pybuildkite",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Buildkite,Continuous Integration,API,CI,wrapper,python",
    "author": "Peter Yasi",
    "author_email": "",
    "download_url": "https://github.com/pyasi/pybuildkite/archive/master.zip",
    "platform": null,
    "description": "# PyBuildkite\n\n[![Build status](https://badge.buildkite.com/89bf10df4492f2f2d61ca707078828824fec3b08cb85192e6d.svg)](https://buildkite.com/pybuildkite/pybuildkite)\n[![Coverage Status](https://coveralls.io/repos/github/pyasi/pybuildkite/badge.svg?branch=master)](https://coveralls.io/github/pyasi/pybuildkite?branch=master)\n[![PyPI most recent version](https://badge.fury.io/py/pybuildkite.svg)](https://pypi.org/project/pybuildkite/)\n[![PyPI downloads](https://img.shields.io/pypi/dm/pybuildkite.svg)](https://pypi.org/project/pybuildkite/)\n\nA [Python](https://www.python.org/) library and client for the [Buildkite API](https://buildkite.com/docs/api).\n\n## Usage\n\nTo get the package, execute:\n\n```\npip install pybuildkite\n```\n\nThen set up an instance of the Buildkite object, set you access token, and make any available requests.\n\n```python\nfrom pybuildkite.buildkite import Buildkite, BuildState\n\nbuildkite = Buildkite()\nbuildkite.set_access_token('YOUR_API_ACCESS_TOKEN_HERE')\n\n# Get all info about particular org\norg = buildkite.organizations().get_org('my-org')\n\n# Get all running and scheduled builds for a particular pipeline\nbuilds = buildkite.builds().list_all_for_pipeline('my-org', 'my-pipeline', states=[BuildState.RUNNING, BuildState.SCHEDULED])\n\n# Create a build\nbuildkite.builds().create_build('my-org', 'my-pipeline', 'COMMITSHA', 'master', \nclean_checkout=True, message=\"My First Build!\")\n```\n\n## Pagination\n\nBuildkite offers pagination for endpoints that return a lot of data. By default this wrapper return `100` objects. However, any request that may contain more than that offers a pagination option.\n\nWhen `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.\n\n```python\nbuilds_response = buildkite.builds().list_all(page=1, with_pagination=True)\n\n# Keep looping until next_page is not populated\nwhile builds_response.next_page:\n    builds_response = buildkite.builds().list_all(page=builds_response.next_page, with_pagination=True)\n```\n\n## Artifacts\n\nArtifacts can be downloaded as binary data. The following example loads the artifact into memory as\n[Python bytes](https://docs.python.org/3/library/stdtypes.html#binary-sequence-types-bytes-bytearray-memoryview)\nand then writes them to disc:\n\n```python\nartifacts = buildkite.artifacts()\nartifact = artifacts.download_artifact(\"org_slug\", \"pipe_slug\", \"build_no\", 123, \"artifact\")\nwith open('artifact.bin', 'b') as f:\n  f.write(artifact)\n```\n\nLarge artifacts should be streamed as chunks of bytes to limit the memory consumption:\n```python\nstream = artifacts.download_artifact(\"org_slug\", \"pipe_slug\", \"build_no\", 123, \"artifact\", as_stream=True)\nwith open('artifact.bin', 'b') as f:\n  for chunk in stream:\n    f.write(chunk)\n```\n\nA unicode text artifact can be turned into a string easily:\n```python\ntext = str(artifact)\n```\n\n## License\n\nThis library is distributed under the BSD-style license found in the LICENSE file.\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python wrapper for the Buildkite API",
    "version": "1.2.3",
    "project_urls": {
        "Download": "https://github.com/pyasi/pybuildkite/archive/master.zip",
        "Homepage": "https://github.com/pyasi/pybuildkite"
    },
    "split_keywords": [
        "buildkite",
        "continuous integration",
        "api",
        "ci",
        "wrapper",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "61a52697921b87f0ea19af1a57142350ad1e47c748c409136c20295c17805091",
                "md5": "3b6a0ce198ba3bf5c614aec6557e68dd",
                "sha256": "d94b162d898efb4c7ee6af6edd4b23c6633f9f09d4b5e67455de5f3799e96db2"
            },
            "downloads": -1,
            "filename": "pybuildkite-1.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3b6a0ce198ba3bf5c614aec6557e68dd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 18157,
            "upload_time": "2023-06-16T13:44:21",
            "upload_time_iso_8601": "2023-06-16T13:44:21.952810Z",
            "url": "https://files.pythonhosted.org/packages/61/a5/2697921b87f0ea19af1a57142350ad1e47c748c409136c20295c17805091/pybuildkite-1.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-16 13:44:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pyasi",
    "github_project": "pybuildkite",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pybuildkite"
}
        
Elapsed time: 0.07963s