{"id":33966339,"url":"https://github.com/bbaga/buildkite-php","last_synced_at":"2026-04-09T04:02:30.984Z","repository":{"id":62492320,"uuid":"195532494","full_name":"bbaga/buildkite-php","owner":"bbaga","description":"PHP client library for consuming the Buildkite API","archived":false,"fork":false,"pushed_at":"2020-09-24T18:59:36.000Z","size":112,"stargazers_count":4,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-02T16:16:53.620Z","etag":null,"topics":["api","buildkite","buildkite-api","cd","ci","composer-package","php","php-library"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bbaga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-06T11:34:37.000Z","updated_at":"2020-09-12T00:16:29.000Z","dependencies_parsed_at":"2022-11-02T09:31:19.582Z","dependency_job_id":null,"html_url":"https://github.com/bbaga/buildkite-php","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/bbaga/buildkite-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbaga%2Fbuildkite-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbaga%2Fbuildkite-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbaga%2Fbuildkite-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbaga%2Fbuildkite-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bbaga","download_url":"https://codeload.github.com/bbaga/buildkite-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbaga%2Fbuildkite-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31584820,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"online","status_checked_at":"2026-04-09T02:00:06.848Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","buildkite","buildkite-api","cd","ci","composer-package","php","php-library"],"created_at":"2025-12-12T23:07:57.578Z","updated_at":"2026-04-09T04:02:30.979Z","avatar_url":"https://github.com/bbaga.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP client library for consuming the Buildkite API\n\n![](https://github.com/bbaga/buildkite-php/workflows/Continous%20Integration/badge.svg)\n![](https://shepherd.dev/github/bbaga/buildkite-php/coverage.svg)\n![](https://codecov.io/gh/bbaga/buildkite-php/branch/master/graph/badge.svg)\n\n## Installation\n```shell script\ncomposer require bbaga/buildkite-php\n```\n\n## Usage\n* [Setting up the API objects](#setting-up-the-api-objects)\n  * [REST API](#rest-api)\n  * [GraphQL API](#graphql-api)\n* [Interacting with Buildkite's GraphQL API](#interacting-with-buildkites-graphql-api)\n* [Interacting with Buildkite's REST API](#interacting-with-buildkites-rest-api)\n  * [Example of traversing through resources](#example-of-traversing-through-resources)\n  * [Accessing resources without traversing](#accessing-resources-without-traversing)\n  * [Creating a new pipeline](#creating-a-new-pipeline)\n* [Direct API calls](#direct-api-calls)\n  * [Organizations API](#organizations-api)\n    * [List the ](#list-the-organizations)\n    * [Get a specific organization](#get-a-specific-organization)\n  * [Pipelines API](#pipelines-api)\n    * [List pipelines in an organization](#list-pipelines-in-an-organizations)\n    * [Get a specific pipeline](#get-a-specific-pipeline)\n    * [Create a pipeline](#create-a-pipeline)\n    * [Update a pipeline](#update-a-pipeline)\n    * [Delete a pipeline](#delete-a-pipelne)\n  * [Builds API](#builds-api)\n    * [List all builds across all the organizations](#list-all-builds-across-all-the-organizations)\n    * [Get a specific build](#get-a-specific-build)\n    * [Get builds in an organization](#get-builds-in-an-organization)\n    * [Get builds for a pipeline](#get-builds-for-a-pipeline)\n    * [Create new build](#create-a-new-build)\n    * [Cancel a running build](#cancel-a-running-build)\n    * [Restarting a build](#restarting-a-build)\n  * [Jobs API](#jobs-api)\n    * [Retry a job](#retry-a-job)\n    * [Unblock a job](#unblock-a-job)\n    * [Get logs for a job](#get-logs-for-a-job)\n    * [Delete logs of a job](#delete-logs-of-a-job)\n    * [Get the environment variables from a job](#get-the-environment-variables-from-a-job)\n  * [Artifacts API](#artifacts-api)\n    * [Get artifacts uploaded from a build](#get-artifacts-uploaded-from-a-build)\n    * [Get artifacts uploaded from a job](#get-artifacts-uploaded-from-a-job)\n    * [Get a specific artifact](#get-a-specific-artifact)\n    * [Delete a specific artifact](#delete-a-specific-artifact)\n  * [Agents API](#agents-api)\n    * [List agents for an organization](#list-agents-for-an-organization)\n    * [Get a specific agent](#get-a-specific-agent)\n    * [Stop an agent](#stop-an-agent)\n  * [Annotations API](#annotations-api)\n    * [Get annotations uploaded by a build](#get-annotations-uploaded-by-a-build)\n  * [Users API](#users-api)\n    * [Get current user](#get-current-user)\n  * [Emojis API](#emojis-api)\n    * [List available emojis](#list-available-emojis)\n\n### Setting up the API objects\n\n`\\Psr\\Http\\Client\\ClientInterface` implementation is available in the [`bbaga/buildkite-php-guzzle-client`](https://github.com/bbaga/buildkite-php-guzzle-client) package.\n\n#### Rest API\n```php\nuse bbaga\\BuildkiteApi\\Api\\RestApi;\n\n/** @var \\Psr\\Http\\Client\\ClientInterface $client */\n$client = new MyHttpClient(); \n\n$api = new RestApi($client, 'MY_BUILDKITE_API_TOKEN');\n```\n\n### GraphQL API\n```php\nuse bbaga\\BuildkiteApi\\Api\\GraphQLApi;\n\n/** @var \\Psr\\Http\\Client\\ClientInterface $client */\n$client = new MyHttpClient(); \n\n$api = new GraphQLApi($client, 'MY_BUILDKITE_API_TOKEN');\n```\n\n### Interacting with Buildkite's GraphQL API\n```php\nuse bbaga\\BuildkiteApi\\Api\\GraphQLApi;\nuse bbaga\\BuildkiteApi\\Api\\GuzzleClient;\n\n$query = '\n    query example($slug: ID!, $first: Int){\n        viewer { user { name } }\n        \n        organization(slug: $slug) {\n            pipelines(first: $first) {\n                edges {\n                    node {\n                        id\n                        slug\n                    }\n                }\n            }\n        } \n    }';\n\n$variables = json_encode(['slug' =\u003e 'my-org', 'first' =\u003e 5]);\n\n$client = new GuzzleClient();\n$api = new GraphQLApi($client, 'MY_BUILDKITE_API_TOKEN');\n\n$api-\u003egetResponseBody($api-\u003epost($query, $variables));\n```\n\n### Interacting with Buildkite's REST API\n\n#### Example of traversing through resources\n```php\nuse bbaga\\BuildkiteApi\\Api\\GuzzleClient;\nuse bbaga\\BuildkiteApi\\Api\\Rest\\Fluent;\nuse bbaga\\BuildkiteApi\\Api\\RestApi;\n\n$client = new GuzzleClient();\n$api = new RestApi($client, 'MY_BUILDKITE_API_TOKEN');\n\n/** Getting all the organizations that are visible with the TOKEN */\n/** @var Fluent\\Organization[] $organizations */\n$organizations = (new Fluent\\Organizations($api))-\u003eget();\n\n/** @var Fluent\\Organization $organization */\n$organization = $organizations[0];\n\n/** @var Fluent\\Pipeline $pipelines */\n$pipelines = $organization-\u003egetPipelines();\n\n/** @var Fluent\\Pipeline $pipeline */\n$pipeline = $pipelines[0];\n\n/** @var Fluent\\Build[] $builds */\n$builds = $pipeline-\u003egetBuilds();\n\n/** @var Fluent\\Build $build */\n$build = $builds[0];\n\n/** @var Fluent\\Job[] $jobs */\n$jobs = $build-\u003egetJobs();\n\n/** @var Fluent\\Emoji[] $emojis */\n$emojis = $organizations[0]-\u003egetEmojis();\n\n/** @var Fluent\\Agent[] $emojis */\n$agents = $organizations[0]-\u003egetAgents();\n```\n\n#### Accessing resources without traversing\n\nFetching data for a specific build without traversing through the hierarchy.\n\n```php\nuse bbaga\\BuildkiteApi\\Api\\GuzzleClient;\nuse bbaga\\BuildkiteApi\\Api\\Rest\\Fluent;\nuse bbaga\\BuildkiteApi\\Api\\RestApi;\n\n$client = new GuzzleClient();\n$api = new RestApi($client, 'MY_BUILDKITE_API_TOKEN');\n\n/**\n * Builds are identified by the follwoing three values \n */\n$organizationSlug = 'my-org';\n$pipelineSlug = 'my-pipeline';\n$buildNumber = 23;\n\n$organization = new Fluent\\Organization($api, ['slug' =\u003e $organizationSlug]);\n$pipeline = new Fluent\\Pipeline($api, $organization, ['slug' =\u003e $pipelineSlug]);\n$build = new Fluent\\Build($api, $organization, ['number' =\u003e $buildNumber, 'pipeline' =\u003e $pipeline]);\n\n$build-\u003efetch()-\u003egetJobs();\n```\n\n#### Creating a new pipeline\n\n```php\nuse bbaga\\BuildkiteApi\\Api\\GuzzleClient;\nuse bbaga\\BuildkiteApi\\Api\\Rest\\Fluent;\nuse bbaga\\BuildkiteApi\\Api\\RestApi;\n\n$client = new GuzzleClient();\n$api = new RestApi($client, 'MY_BUILDKITE_API_TOKEN');\n\n$organization = new Fluent\\Organization($api, ['slug' =\u003e 'my-org']);\n$pipeline = $organization-\u003ecreatePipeline(\n    [\n        'name' =\u003e 'my-pipeline',\n        'repository' =\u003e 'git@github.com:some/repo.git',\n        'steps' =\u003e [\n            [\n                'type' =\u003e 'script',\n                'name' =\u003e 'upload artifact',\n                'command' =\u003e 'echo \"Hello\" \u003e artifact.txt \\\n                 \u0026\u0026 buildkite-agent artifact upload artifact.txt \\\n                 \u0026\u0026 cat artifact.txt | buildkite-agent annotate --style \"success\" --context \"junit\"',\n            ],\n            [\n                'type' =\u003e 'manual',\n                'name' =\u003e 'Needs to be unblocked',\n                'command' =\u003e 'echo \"Unblocked!\"',\n            ],\n        ]\n    ]\n);\n\n/**\n * Pipeline is ready, we can kick off the first build\n */\n$buildSettings = [\n    'commit' =\u003e 'HEAD',\n    'branch' =\u003e 'master',\n    'message' =\u003e 'Testing all the things :rocket:',\n];\n\n$pipeline-\u003ecreateBuild($buildSettings);\n```\n\n### Direct API calls\n\n### Organizations API\n\nOrganizations related methods are exposed via `$api-\u003eorganization()`\n\nDetailed documentation for the Organizations API is available [here](https://buildkite.com/docs/apis/rest-api/organizations)\n\n#### List the organizations\n\n```php\n$api-\u003eorganization()-\u003elist();\n```\n\n#### Get a specific organization\n```php\n$api-\u003eorganization()-\u003eget('my-organization');\n```\n\n### Pipelines API\n\nPipelines related methods are exposed via `$api-\u003epipeline()`\n\nDetailed documentation for the Pipelines API is available [here](https://buildkite.com/docs/apis/rest-api/pipelines)\n\n#### List pipelines in an organizations\n```php\n$api-\u003epipeline()-\u003elist('my-organizations');\n```\n\n#### Get a specific pipeline\n```php\n$api-\u003epipeline()-\u003eget('my-organization', 'my-pipeline');\n```\n\n#### Create a pipeline\n```php\n$pipelineData = [\n    'name' =\u003e 'My Pipeline',\n    'repository' =\u003e 'git@github.com:acme-inc/my-pipeline.git',\n    'steps' =\u003e [\n        [\n            'type' =\u003e 'script',\n            'name' =\u003e 'Build :package:',\n            'command' =\u003e 'script/release.sh',\n        ],\n    ],\n];\n\n$api-\u003epipeline()-\u003ecreate('my-organization', $pipelineData);\n```\n\n#### Update a pipeline\n```php\n$pipelineData = [\n    'repository' =\u003e 'git@github.com:acme-inc/new-repo.git',\n];\n\n$api-\u003epipeline()-\u003eupdate('my-organization', 'my-pipelines', $pipelineData);\n```\n\n#### Delete a pipelne\n```php\n$api-\u003epipeline()-\u003edelete('my-organization', 'my-pipeline');\n```\n\n### Builds API\n\nBuilds related methods are exposed via `$api-\u003ebuild()`\n\nDetailed documentation for the Builds API is available [here](https://buildkite.com/docs/apis/rest-api/builds)\n\n#### List all builds across all the organizations\n```php\n$api-\u003ebuild()-\u003elistAll($queryParameters);\n```\n\n#### Get a specific build\n```php\n$buildNumber = 1;\n$api-\u003ebuild()-\u003eget('my-organization', 'my-pipeline', $buildNumber);\n```\n\n#### Get builds in an organization\n```php\n$api-\u003ebuild()-\u003egetByOrganization('my-organization', $queryParameters);\n```\n\n#### Get builds for a pipeline\n```php\n$api-\u003ebuild()-\u003egetByPipeline('my-organization', 'my-pipeline', $queryParameters);\n```\n\n#### Create a new build\n```php\n$buildSettings = [\n    'commit' =\u003e 'abcd0b72a1e580e90712cdd9eb26d3fb41cd09c8',\n    'branch' =\u003e 'master',\n    'message' =\u003e 'Testing all the things :rocket:',\n    'author' =\u003e [\n        'name' =\u003e 'Keith Pitt',\n        'email' =\u003e 'me@keithpitt.com',\n    ],\n    'env' =\u003e [\n        'MY_ENV_VAR' =\u003e 'some_value',\n    ],\n    'meta_data' =\u003e [\n        'some build data' =\u003e 'value',\n        'other build data' =\u003e true,\n    ],\n];\n\n$api-\u003ebuild()-\u003ecreate('my-organization', 'my-pipeline', $buildSettings);\n```\n\n#### Cancel a running build\n```php\n$buildNumber = 12;\n$api-\u003ebuild()-\u003ecancel('my-organization', 'my-pipeline', $buildNumber);\n```\n\n#### Restarting a build\n```php\n$buildNumber = 12;\n$api-\u003ebuild()-\u003erebuild('my-organization', 'my-pipeline', $buildNumber);\n```\n\n### Jobs API\n\nJobs related methods are exposed via `$api-\u003ejob()`\n\nDetailed documentation for the Jobs API is available [here](https://buildkite.com/docs/apis/rest-api/jobs)\n\n#### Retry a job\n```php\n$buildNumber = 12;\n$jobId = '0738da5f-0372-4b02-a1cb-f07a12fbcdcd';\n\n$api-\u003ejob()-\u003eretry('my-organization', 'my-pipeline', $buildNumber, $jobId);\n```\n\n#### Unblock a job\n```php\n$buildNumber = 12;\n$jobId = '0738da5f-0372-4b02-a1cb-f07a12fbcdcd';\n\n$api-\u003ejob()-\u003eunblock('my-organization', 'my-pipeline', $buildNumber, $jobId);\n```\n\n#### Get logs for a job\n```php\n$buildNumber = 12;\n$jobId = '0738da5f-0372-4b02-a1cb-f07a12fbcdcd';\n\n$api-\u003ejob()-\u003egetLogOutput('my-organization', 'my-pipeline', $buildNumber, $jobId);\n```\n\n#### Delete logs of a job\n```php\n$buildNumber = 12;\n$jobId = '0738da5f-0372-4b02-a1cb-f07a12fbcdcd';\n\n$api-\u003ejob()-\u003edeleteLogOutput('my-organization', 'my-pipeline', $buildNumber, $jobId);\n```\n\n#### Get the environment variables from a job\n```php\n$buildNumber = 12;\n$jobId = '0738da5f-0372-4b02-a1cb-f07a12fbcdcd';\n\n$api-\u003ejob()-\u003egetEnvironmentVariables('my-organization', 'my-pipeline', $buildNumber, $jobId);\n```\n\n### Artifacts API\n\nJobs related methods are exposed via `$api-\u003eartifact()`\n\nDetailed documentation for the Artifacts API is available [here](https://buildkite.com/docs/apis/rest-api/artifacts)\n\n#### Get artifacts uploaded from a build\n```php\n$buildNumber = 12;\n$api-\u003eartifact()-\u003egetByBuild('my-organization', 'my-pipeline', $buildNumber);\n```\n\n#### Get artifacts uploaded from a job\n```php\n$buildNumber = 12;\n$jobId = '0738da5f-0372-4b02-a1cb-f07a12fbcdcd';\n\n$api-\u003eartifact()-\u003egetByJob('my-organization', 'my-pipeline', $buildNumber, $jobId);\n```\n\n#### Get a specific artifact\n```php\n$buildNumber = 12;\n$jobId = '0738da5f-0372-4b02-a1cb-f07a12fbcdcd';\n$artifactId = '567038da5f03724b02a1cbf07a12fbcedfg';\n\n$api-\u003eartifact()-\u003eget(\n    'my-organization',\n    'my-pipeline',\n    $buildNumber,\n    $jobId,\n    $artifactId\n);\n```\n\n#### Delete a specific artifact\n```php\n$buildNumber = 12;\n$jobId = '0738da5f-0372-4b02-a1cb-f07a12fbcdcd';\n$artifactId = '567038da5f03724b02a1cbf07a12fbcedfg';\n\n$api-\u003eartifact()-\u003edelete(\n    'my-organization',\n    'my-pipeline',\n    $buildNumber,\n    $jobId,\n    $artifactId\n);\n```\n\n### Agents API\n\nAgents related methods are exposed via `$api-\u003eagent()`\n\nDetailed documentation for the Agents API is available [here](https://buildkite.com/docs/apis/rest-api/agents)\n\n#### List agents for an organization\n```php\n$api-\u003eagent()-\u003elist('my-organization');\n```\n\n#### Get a specific agent\n```php\n$agentId = '1d633306-de28-4944-ad84-fde0d50a6c9e';\n$api-\u003eagent()-\u003elist('my-organization', $agentId);\n```\n\n#### Stop an agent\n```php\n$agentId = '1d633306-de28-4944-ad84-fde0d50a6c9e';\n$api-\u003eagent()-\u003elist('my-organization', $agentId);\n```\n\n### Annotations API\n\nAnnotations related methods are exposed via `$api-\u003eannotation()`\n\nDetailed documentation for the Annotations API is available [here](https://buildkite.com/docs/apis/rest-api/annotations)\n\n#### Get annotations uploaded by a build\n```php\n$buildNumber = 12;\n$api-\u003eannotation()-\u003elist('my-organization', 'my-pipeline', $buildNumber);\n```\n\n### Users API\n\nUsers related methods are exposed via `$api-\u003euser()`\n\nDetailed documentation for the Users API is available [here](https://buildkite.com/docs/apis/rest-api/users)\n\n#### Get current user\n```php\n$api-\u003euser()-\u003ewhoami();\n```\n\n### Emojis API\n\nEmojis related methods are exposed via `$api-\u003eemoji()`\n\nDetailed documentation for the Users API is available [here](https://buildkite.com/docs/apis/rest-api/emojis)\n\n#### List available emojis\n```php\n$api-\u003eemoji()-\u003elist('my-organization');\n```\n\n## Contribution\n\n### Testing\n\n```shell script\nmake test\n```\n\n### Integration testing\nA Buildkite account and a running agent is required for integration testing and the following environment variables must be set.\n\n* `BK_TEST_TOKEN`\n* `BK_TEST_ORG`\n* `BK_TEST_PREFIX`\n* `GITHUB_REF`\n* `GITHUB_REPOSITORY`\n\nThese can be set in the `phpunit.xml` by making a copy of `phpunit.xml.dist` and extending it with the following snippet\n```xml\n    \u003cphp\u003e\n        \u003cenv name=\"BK_TEST_TOKEN\" value=\"my-buildkite-api-token\"/\u003e\n        \u003cenv name=\"BK_TEST_ORG\" value=\"my-organization-slug\"/\u003e\n        \u003cenv name=\"BK_TEST_PREFIX\" value=\"something-uniqe\"/\u003e\n        \u003cenv name=\"GITHUB_REF\" value=\"refs/heads/master\"/\u003e\n        \u003cenv name=\"GITHUB_REPOSITORY\" value=\"your-name/buildkite-php\"/\u003e\n    \u003c/php\u003e\n```\n\nOnce the environment variables are set the test suite can be started\n\n```shell script\nmake integration\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbaga%2Fbuildkite-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbaga%2Fbuildkite-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbaga%2Fbuildkite-php/lists"}