switchroom 0.13.2 → 0.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/agent-scheduler/index.js +2 -2
  2. package/dist/auth-broker/index.js +2 -2
  3. package/dist/cli/switchroom.js +21 -18
  4. package/dist/host-control/main.js +2 -2
  5. package/dist/vault/approvals/kernel-server.js +2 -2
  6. package/dist/vault/broker/server.js +2 -2
  7. package/package.json +1 -1
  8. package/telegram-plugin/dist/gateway/gateway.js +42 -10
  9. package/telegram-plugin/gateway/boot-probes.ts +13 -6
  10. package/telegram-plugin/gateway/gateway.ts +44 -6
  11. package/telegram-plugin/hooks/silent-end-interrupt-stop.mjs +5 -1
  12. package/telegram-plugin/silent-end.ts +56 -0
  13. package/telegram-plugin/tests/boot-probes.test.ts +26 -2
  14. package/telegram-plugin/tests/silent-end.test.ts +69 -0
  15. package/skills/buildkite-agent-infrastructure/SKILL.md +0 -321
  16. package/skills/buildkite-agent-infrastructure/agents/openai.yaml +0 -6
  17. package/skills/buildkite-agent-infrastructure/assets/buildkite-icon-large.png +0 -0
  18. package/skills/buildkite-agent-infrastructure/assets/buildkite-icon-small.png +0 -0
  19. package/skills/buildkite-agent-infrastructure/references/audit-logging.md +0 -87
  20. package/skills/buildkite-agent-infrastructure/references/graphql-mutations.md +0 -690
  21. package/skills/buildkite-agent-infrastructure/references/instance-shapes.md +0 -38
  22. package/skills/buildkite-agent-infrastructure/references/pipeline-templates.md +0 -73
  23. package/skills/buildkite-agent-infrastructure/references/self-hosted-agents.md +0 -137
  24. package/skills/buildkite-agent-infrastructure/references/sso-saml.md +0 -92
  25. package/skills/buildkite-agent-runtime/SKILL.md +0 -509
  26. package/skills/buildkite-agent-runtime/agents/openai.yaml +0 -6
  27. package/skills/buildkite-agent-runtime/assets/buildkite-icon-large.png +0 -0
  28. package/skills/buildkite-agent-runtime/assets/buildkite-icon-small.png +0 -0
  29. package/skills/buildkite-agent-runtime/references/flag-reference.md +0 -417
  30. package/skills/buildkite-agent-runtime/references/patterns-and-recipes.md +0 -555
  31. package/skills/buildkite-api/SKILL.md +0 -308
  32. package/skills/buildkite-api/agents/openai.yaml +0 -6
  33. package/skills/buildkite-api/assets/buildkite-icon-large.png +0 -0
  34. package/skills/buildkite-api/assets/buildkite-icon-small.png +0 -0
  35. package/skills/buildkite-api/references/graphql-reference.md +0 -195
  36. package/skills/buildkite-api/references/patterns.md +0 -44
  37. package/skills/buildkite-api/references/webhooks.md +0 -161
  38. package/skills/buildkite-cli/SKILL.md +0 -397
  39. package/skills/buildkite-cli/agents/openai.yaml +0 -6
  40. package/skills/buildkite-cli/assets/buildkite-icon-large.png +0 -0
  41. package/skills/buildkite-cli/assets/buildkite-icon-small.png +0 -0
  42. package/skills/buildkite-cli/references/command-reference.md +0 -181
  43. package/skills/buildkite-migration/SKILL.md +0 -195
  44. package/skills/buildkite-pipelines/SKILL.md +0 -481
  45. package/skills/buildkite-pipelines/agents/openai.yaml +0 -6
  46. package/skills/buildkite-pipelines/assets/buildkite-icon-large.png +0 -0
  47. package/skills/buildkite-pipelines/assets/buildkite-icon-small.png +0 -0
  48. package/skills/buildkite-pipelines/examples/basic-pipeline.yml +0 -24
  49. package/skills/buildkite-pipelines/examples/optimized-pipeline.yml +0 -100
  50. package/skills/buildkite-pipelines/references/advanced-patterns.md +0 -286
  51. package/skills/buildkite-pipelines/references/retry-and-error-codes.md +0 -131
  52. package/skills/buildkite-pipelines/references/step-types-reference.md +0 -225
  53. package/skills/buildkite-secure-delivery/SKILL.md +0 -182
  54. package/skills/buildkite-secure-delivery/agents/openai.yaml +0 -6
  55. package/skills/buildkite-secure-delivery/assets/buildkite-icon-large.png +0 -0
  56. package/skills/buildkite-secure-delivery/assets/buildkite-icon-small.png +0 -0
  57. package/skills/buildkite-secure-delivery/references/oidc-cloud-providers.md +0 -83
  58. package/skills/buildkite-secure-delivery/references/package-publishing.md +0 -100
  59. package/skills/buildkite-test-engine/SKILL.md +0 -256
  60. package/skills/buildkite-test-engine/agents/openai.yaml +0 -6
  61. package/skills/buildkite-test-engine/assets/buildkite-icon-large.png +0 -0
  62. package/skills/buildkite-test-engine/assets/buildkite-icon-small.png +0 -0
  63. package/skills/buildkite-test-engine/examples/bktec-splitting.yml +0 -16
  64. package/skills/buildkite-test-engine/examples/collector-pipeline.yml +0 -11
  65. package/skills/buildkite-test-engine/references/collectors.md +0 -198
  66. package/skills/buildkite-test-engine/references/splitting-examples.md +0 -93
@@ -1,308 +0,0 @@
1
- ---
2
- name: buildkite-api
3
- description: >
4
- Use when the user wants direct programmatic access to Buildkite —
5
- calling the REST API (`api.buildkite.com`), writing GraphQL queries
6
- or mutations (`graphql.buildkite.com`), handling webhook events,
7
- paginating API results, automating Buildkite from a script, or
8
- building any integration that hits Buildkite endpoints. Triggers on
9
- phrasings including: "Please write a GraphQL query.", "Let's
10
- paginate API results.", "Could you automate Buildkite for me?",
11
- "Automate Buildkite, please.", "Can you authenticate with the
12
- Buildkite API?", "handle webhook events", "paginate results",
13
- "write a script that calls Buildkite", "hey, automate Buildkite?",
14
- "any way to write a GraphQL query?", and typo'd variants like
15
- "authenticate with the Buildkite API", "write a GraaphQL query",
16
- "integrate with Buildikte programmatically". Also fires on indirect
17
- signals like "the buildkite-api thing is weird", "can you take a
18
- look at the buildkite-api situation", "something is going on with
19
- buildkite-api", and on mentions of `api.buildkite.com`,
20
- `graphql.buildkite.com`, REST endpoints, GraphQL mutations, webhook
21
- payloads, API tokens, or programmatic access to Buildkite data.
22
- Whenever the user's message starts with the phrase "Calling the
23
- Buildkite REST/GraphQL API," — regardless of what follows — use
24
- this skill.
25
- Do NOT use for interactive `bk` CLI usage — that's `buildkite-cli`. Do
26
- NOT use for authoring `.buildkite/pipeline.yml` — that's
27
- `buildkite-pipelines`. Do NOT use for `buildkite-agent <subcommand>`
28
- inside a step — that's `buildkite-agent-runtime`. Do NOT use when the
29
- user's message starts with "In Buildkite cluster admin," — that
30
- prefix is a hard trigger for `buildkite-agent-infrastructure` (which
31
- owns SSO/SAML setup, queue scaling, agent tokens, cluster secrets,
32
- audit logging, and pipeline templates) even when the underlying
33
- implementation would use GraphQL mutations; cluster-admin intent
34
- routes to infrastructure, not this generic API skill.
35
- ---
36
-
37
- # Buildkite API
38
-
39
- Buildkite exposes a REST API and a GraphQL API for programmatic automation, plus webhooks for event-driven integrations. Use the REST API for straightforward CRUD operations on builds, pipelines, and organizations. Use the GraphQL API for mutations (queue creation, template management, cluster operations) and when fetching nested or specific fields. Use webhooks to react to build and agent events in real time.
40
-
41
- > To execute API calls interactively from the terminal, see the **buildkite-cli** skill for `bk api` commands. To use the Buildkite MCP server for direct agent access to builds, logs, and pipelines, the MCP server exposes its own tool schemas — no API construction needed.
42
-
43
- ## Quick Start
44
-
45
- List builds for a pipeline using the REST API:
46
-
47
- ```bash
48
- curl -sS -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
49
- "https://api.buildkite.com/v2/organizations/my-org/pipelines/my-pipeline/builds?per_page=5" | jq '.[].state'
50
- ```
51
-
52
- Query the same data via GraphQL:
53
-
54
- ```bash
55
- curl -sS -X POST "https://graphql.buildkite.com/v1" \
56
- -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
57
- -H "Content-Type: application/json" \
58
- -d '{
59
- "query": "{ pipeline(slug: \"my-org/my-pipeline\") { builds(first: 5) { edges { node { state message } } } } }"
60
- }' | jq '.data.pipeline.builds.edges[].node'
61
- ```
62
-
63
- ## Authentication
64
-
65
- ### Bearer Token
66
-
67
- All API requests require a Buildkite API access token passed as a Bearer token:
68
-
69
- ```bash
70
- curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
71
- "https://api.buildkite.com/v2/organizations"
72
- ```
73
-
74
- Create tokens at **Buildkite → Personal Settings → API Access Tokens**. Each token is scoped to specific organizations and permissions.
75
-
76
- ### Token Scopes
77
-
78
- | Scope | Grants access to |
79
- |-------|-----------------|
80
- | `read_builds` / `write_builds` | List/inspect or create/cancel/retry builds |
81
- | `read_pipelines` / `write_pipelines` | List/inspect or create/update/delete pipelines |
82
- | `read_artifacts` / `write_artifacts` | Download or upload/delete artifacts |
83
- | `read_build_logs` / `write_build_logs` | Read or delete job log output |
84
- | `read_agents` / `write_agents` | List/inspect or stop/manage agents |
85
- | `read_organizations` | List organizations |
86
- | `read_teams` | List teams and memberships |
87
- | `read_job_env` | Retrieve job environment variables |
88
- | `read_user` | Inspect the authenticated user |
89
- | `read_clusters` / `write_clusters` | List/inspect or manage clusters and queues |
90
- | `read_suites` / `write_suites` | List/inspect or manage Test Engine suites |
91
- | `read_registries` / `write_registries` | List/inspect or manage package registries |
92
-
93
- Grant the minimum scopes required. A CI automation script that only triggers builds needs `write_builds` and `read_pipelines` — nothing else.
94
-
95
- ### JWT Authentication (Public Key)
96
-
97
- For machine-to-machine integrations without long-lived tokens, sign RS256 JWTs with claims `iss` (API token UUID), `iat` (within 10 seconds of server time), and `exp` (within 5 minutes of `iat`). Register the public key in Buildkite, then use the JWT as a bearer token.
98
-
99
- ```python
100
- import jwt, time
101
- now = int(time.time())
102
- token = jwt.encode({"iss": "your-token-uuid", "iat": now, "exp": now + 300},
103
- open("private_key.pem").read(), algorithm="RS256")
104
- headers = {"Authorization": f"Bearer {token}"}
105
- ```
106
-
107
- ## REST API
108
-
109
- Base URL: `https://api.buildkite.com/v2`
110
-
111
- All responses return JSON. Use `Content-Type: application/json` for request bodies.
112
-
113
- ### Endpoint Reference
114
-
115
- All endpoints are under `/organizations/{org.slug}`. Abbreviated as `/{org}` below.
116
-
117
- | Resource | Endpoint | Methods | Scope |
118
- |----------|----------|---------|-------|
119
- | Organizations | `/organizations` | GET | `read_organizations` |
120
- | Pipelines | `/{org}/pipelines` | GET, POST | `read_pipelines`, `write_pipelines` |
121
- | Pipeline | `/{org}/pipelines/{slug}` | GET, PUT, PATCH, DELETE | `read_pipelines`, `write_pipelines` |
122
- | Builds (org) | `/{org}/builds` | GET | `read_builds` |
123
- | Builds (pipeline) | `/{org}/pipelines/{slug}/builds` | GET, POST | `read_builds`, `write_builds` |
124
- | Build | `/{org}/pipelines/{slug}/builds/{num}` | GET | `read_builds` |
125
- | Jobs | `/{org}/pipelines/{slug}/builds/{num}/jobs` | GET | `read_builds` |
126
- | Job log | `/{org}/pipelines/{slug}/builds/{num}/jobs/{id}/log` | GET, DELETE | `read_build_logs` |
127
- | Job env | `/{org}/pipelines/{slug}/builds/{num}/jobs/{id}/env` | GET | `read_job_env` |
128
- | Artifacts (build) | `/{org}/pipelines/{slug}/builds/{num}/artifacts` | GET | `read_artifacts` |
129
- | Artifact download | `/{org}/pipelines/{slug}/builds/{num}/artifacts/{id}/download` | GET | `read_artifacts` |
130
- | Annotations | `/{org}/pipelines/{slug}/builds/{num}/annotations` | GET | `read_builds` |
131
- | Agents | `/{org}/agents` | GET | `read_agents` |
132
- | Agent tokens | `/{org}/agent-tokens` | GET, POST | `read_agents`, `write_agents` |
133
- | Members | `/{org}/members` | GET | `read_organizations` |
134
- | Webhooks | `/{org}/webhooks` | GET, POST | — |
135
-
136
- ### Pagination
137
-
138
- REST responses are paginated using HTTP `Link` headers:
139
-
140
- ```
141
- Link: <https://api.buildkite.com/v2/organizations/my-org/builds?page=2&per_page=30>; rel="next",
142
- <https://api.buildkite.com/v2/organizations/my-org/builds?page=5&per_page=30>; rel="last"
143
- ```
144
-
145
- | Parameter | Default | Max | Description |
146
- |-----------|---------|-----|-------------|
147
- | `page` | `1` | — | Page number |
148
- | `per_page` | `30` | `100` | Results per page |
149
-
150
- Parse the `Link` header to follow `rel="next"` until no next link exists.
151
-
152
- ### List Builds
153
-
154
- ```bash
155
- # Filter by state and branch
156
- curl -sS -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
157
- "https://api.buildkite.com/v2/organizations/my-org/pipelines/my-pipeline/builds?state=failed&branch=main"
158
- ```
159
-
160
- Build list query parameters:
161
-
162
- | Parameter | Description | Example |
163
- |-----------|-------------|---------|
164
- | `state` | Filter: `running`, `scheduled`, `passed`, `failed`, `blocked`, `canceled`, `skipped`, `finished` | `state=failed` |
165
- | `state[]` | Multiple states | `state[]=running&state[]=scheduled` |
166
- | `branch` | Branch name | `branch=main` |
167
- | `commit` | Commit SHA | `commit=abc123` |
168
- | `created_from` | Builds after (ISO 8601) | `created_from=2024-01-01T00:00:00Z` |
169
- | `created_to` | Builds before (ISO 8601) | `created_to=2024-12-31T23:59:59Z` |
170
- | `include_retried_jobs` | Include retried executions | `include_retried_jobs=true` |
171
- | `meta_data` | Filter by metadata | `meta_data[deploy]=true` |
172
-
173
- ### Create a Build
174
-
175
- ```bash
176
- curl -sS -X POST "https://api.buildkite.com/v2/organizations/my-org/pipelines/my-pipeline/builds" \
177
- -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
178
- -H "Content-Type: application/json" \
179
- -d '{
180
- "commit": "HEAD",
181
- "branch": "main",
182
- "message": "Triggered via API",
183
- "env": {
184
- "DEPLOY_TARGET": "staging"
185
- },
186
- "meta_data": {
187
- "triggered_by": "automation"
188
- }
189
- }'
190
- ```
191
-
192
- | Field | Required | Description |
193
- |-------|----------|-------------|
194
- | `commit` | Yes | Git ref, SHA, or `HEAD` |
195
- | `branch` | Yes | Branch name |
196
- | `message` | No | Build message (defaults to commit message) |
197
- | `env` | No | Environment variables (object) |
198
- | `meta_data` | No | Build metadata (object) — accessible via `buildkite-agent meta-data` |
199
- | `clean_checkout` | No | Force clean checkout (`true`/`false`) |
200
- | `ignore_pipeline_branch_filters` | No | Skip branch filtering rules |
201
-
202
- Also supports `author` (object: `name`, `email`), `pull_request_id`, `pull_request_base_branch`, `pull_request_repository`.
203
-
204
- ### Rebuild a Build
205
-
206
- ```bash
207
- curl -sS -X PUT "https://api.buildkite.com/v2/organizations/my-org/pipelines/my-pipeline/builds/42/rebuild" \
208
- -H "Authorization: Bearer $BUILDKITE_API_TOKEN"
209
- ```
210
-
211
- ### Cancel a Build
212
-
213
- ```bash
214
- curl -sS -X PUT "https://api.buildkite.com/v2/organizations/my-org/pipelines/my-pipeline/builds/42/cancel" \
215
- -H "Authorization: Bearer $BUILDKITE_API_TOKEN"
216
- ```
217
-
218
- ### Download Artifacts
219
-
220
- Two-step process: list artifacts for a build, then download by artifact ID. The download endpoint returns a redirect — use `-L` to follow it:
221
-
222
- ```bash
223
- curl -sS -L -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
224
- "https://api.buildkite.com/v2/organizations/my-org/pipelines/my-pipeline/builds/42/artifacts/$ARTIFACT_ID/download" \
225
- -o artifact.tar.gz
226
- ```
227
-
228
- ### Create a Pipeline
229
-
230
- ```bash
231
- curl -sS -X POST "https://api.buildkite.com/v2/organizations/my-org/pipelines" \
232
- -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
233
- -H "Content-Type: application/json" \
234
- -d '{
235
- "name": "My Pipeline",
236
- "repository": "git@github.com:my-org/my-repo.git",
237
- "steps": [{"type": "script", "name": "Test", "command": "make test"}],
238
- "default_branch": "main"
239
- }'
240
- ```
241
-
242
- ### Error Handling
243
-
244
- API errors return JSON with a `message` field.
245
-
246
- | Status code | Meaning | Common cause |
247
- |-------------|---------|--------------|
248
- | `401` | Unauthorized | Invalid or expired token |
249
- | `403` | Forbidden | Token lacks required scope |
250
- | `404` | Not found | Wrong org/pipeline slug, or insufficient permissions |
251
- | `422` | Unprocessable entity | Invalid request body (missing required field, bad value) |
252
- | `429` | Rate limited | Too many requests — read `Retry-After` header and wait |
253
-
254
- ## GraphQL API
255
-
256
- Endpoint: `https://graphql.buildkite.com/v1`. The GraphQL API supports queries and mutations with cursor-based pagination. Use it for operations not available in the REST API (cluster management, pipeline templates, complex mutations) and when fetching nested or specific fields to reduce response size.
257
-
258
- > For full query/mutation examples, pagination details, and introspection guidance, see `references/graphql-reference.md`.
259
-
260
- ### REST vs GraphQL Decision Guide
261
-
262
- | Scenario | Use | Why |
263
- |----------|-----|-----|
264
- | Trigger a build | Either | Both support it; REST is simpler |
265
- | List builds with filtering | REST | Better query parameter support |
266
- | Fetch build + jobs + artifacts in one call | GraphQL | Single request, no N+1 |
267
- | Create or update cluster queues | GraphQL | Not available in REST |
268
- | Create pipeline templates | GraphQL | Not available in REST |
269
- | Manage agent tokens | GraphQL | More control than REST |
270
- | Simple CRUD on pipelines | REST | Simpler request/response |
271
- | Audit events | GraphQL | `auditEvent` query available |
272
- | Bulk operations on many pipelines | GraphQL | Fetch specific fields only, reduce payload size |
273
-
274
- ## Webhooks
275
-
276
- Webhooks deliver HTTP POST requests to a specified URL when events occur in Buildkite. Use them for event-driven automation: failure notifications, auto-retry logic, deployment triggers, status dashboards. Configure via the REST API at `/{org}/webhooks` with a target URL, event subscriptions, and optional HMAC-SHA256 signature verification.
277
-
278
- Most commonly used events: `build.finished` (react to build completion), `job.finished` (react to individual job results), `build.failing` (early failure notification). Agent events (`agent.connected`, `agent.disconnected`, etc.) and job lifecycle events are also available.
279
-
280
- > For webhook creation parameters, payload structure, HTTP headers, signature verification code, and a complete handler example, see `references/webhooks.md`.
281
-
282
- ## Common Mistakes
283
-
284
- | Mistake | What happens | Fix |
285
- |---------|-------------|-----|
286
- | Using pipeline slug as GraphQL `pipelineID` | Mutation fails with "not found" error | Query the pipeline first to get its `id` (base64-encoded GraphQL node ID), then use that in mutations |
287
- | Missing `Content-Type: application/json` on POST requests | 422 error or empty response body | Always include `-H "Content-Type: application/json"` for POST/PUT/PATCH requests |
288
- | Not following `Link` header pagination | Only get first 30 results, missing data | Parse the `Link` header for `rel="next"` and loop until no next link exists |
289
- | Using `per_page` above 100 | Silently capped at 100, appears to work but data is incomplete | Set `per_page=100` maximum and paginate for larger result sets |
290
- | Ignoring `429` rate limit responses | Subsequent requests fail or get blocked | Read the `Retry-After` header and wait before retrying |
291
- | Comparing webhook signatures with `==` instead of timing-safe comparison | Vulnerable to timing attacks | Use `crypto.timingSafeEqual` (Node.js) or `hmac.compare_digest` (Python) |
292
- | Sending `env` as a string instead of object in build creation | 422 error | `env` must be a JSON object: `{"KEY": "value"}`, not `"KEY=value"` |
293
- | Using REST API for cluster/queue management | 404 — endpoints do not exist | Use the GraphQL API for cluster and queue operations (`clusterQueueCreate`, etc.) |
294
-
295
- ## Additional Resources
296
-
297
- - `references/graphql-reference.md` — Full GraphQL query/mutation examples, pagination, introspection
298
- - `references/webhooks.md` — Webhook creation, payload structure, signature verification, handler example
299
- - `references/patterns.md` — Common API usage patterns: fetching failed builds, build success rates, triggering downstream pipelines
300
-
301
- ## Further Reading
302
-
303
- - [Buildkite Docs for LLMs](https://buildkite.com/docs/llms.txt)
304
- - [Buildkite REST API reference](https://buildkite.com/docs/apis/rest-api.md)
305
- - [Buildkite GraphQL API documentation](https://buildkite.com/docs/apis/graphql-api.md)
306
- - [Buildkite GraphQL Explorer](https://buildkite.com/docs/apis/graphql/graphql-tutorial.md)
307
- - [Buildkite Webhooks guide](https://buildkite.com/docs/apis/webhooks.md)
308
- - [API authentication and token management](https://buildkite.com/docs/apis/managing-api-tokens.md)
@@ -1,6 +0,0 @@
1
- interface:
2
- display_name: "Buildkite API"
3
- short_description: "REST API, GraphQL API, and webhooks for programmatic automation"
4
- icon_small: "./assets/buildkite-icon-small.png"
5
- icon_large: "./assets/buildkite-icon-large.png"
6
- brand_color: "#00D974"
@@ -1,195 +0,0 @@
1
- # GraphQL API Reference
2
-
3
- Endpoint: `https://graphql.buildkite.com/v1`
4
-
5
- The GraphQL API supports queries and mutations with cursor-based pagination. Use it for operations not available in the REST API (cluster management, pipeline templates, complex mutations) and when fetching nested or specific fields to reduce response size.
6
-
7
- ## Basic Query
8
-
9
- ```bash
10
- curl -sS -X POST "https://graphql.buildkite.com/v1" \
11
- -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
12
- -H "Content-Type: application/json" \
13
- -d '{
14
- "query": "query { viewer { user { name email } } }"
15
- }'
16
- ```
17
-
18
- ## Cursor-Based Pagination
19
-
20
- GraphQL uses cursor-based pagination via the `Connection` pattern:
21
-
22
- ```graphql
23
- query PaginatedBuilds($cursor: String) {
24
- pipeline(slug: "my-org/my-pipeline") {
25
- builds(first: 50, after: $cursor) {
26
- pageInfo {
27
- hasNextPage
28
- endCursor
29
- }
30
- edges {
31
- node {
32
- number
33
- state
34
- message
35
- createdAt
36
- }
37
- }
38
- }
39
- }
40
- }
41
- ```
42
-
43
- | Parameter | Description |
44
- |-----------|-------------|
45
- | `first` | Return the first N results (forward pagination) |
46
- | `after` | Cursor to start after (from `pageInfo.endCursor`) |
47
- | `last` | Return the last N results (backward pagination) |
48
- | `before` | Cursor to start before (from `pageInfo.startCursor`) |
49
-
50
- `PageInfo` fields:
51
-
52
- | Field | Description |
53
- |-------|-------------|
54
- | `hasNextPage` | More results exist after the current page |
55
- | `hasPreviousPage` | More results exist before the current page |
56
- | `startCursor` | Cursor of the first item in this page |
57
- | `endCursor` | Cursor of the last item in this page |
58
-
59
- To paginate: query with `first: N`, read `pageInfo.endCursor`, pass it as `after` in the next request. Loop until `hasNextPage` is `false`.
60
-
61
- ## Key Queries
62
-
63
- **Get build with job details:**
64
-
65
- ```graphql
66
- query {
67
- build(slug: "my-org/my-pipeline/42") {
68
- number
69
- state
70
- message
71
- branch
72
- commit
73
- createdAt
74
- finishedAt
75
- jobs(first: 50) {
76
- edges {
77
- node {
78
- ... on JobTypeCommand {
79
- label
80
- state
81
- exitStatus
82
- startedAt
83
- finishedAt
84
- }
85
- }
86
- }
87
- }
88
- }
89
- }
90
- ```
91
-
92
- **List clusters and queues:**
93
-
94
- ```graphql
95
- query {
96
- organization(slug: "my-org") {
97
- clusters(first: 10) {
98
- edges {
99
- node {
100
- name
101
- uuid
102
- queues(first: 20) {
103
- edges { node { key description } }
104
- }
105
- }
106
- }
107
- }
108
- }
109
- }
110
- ```
111
-
112
- ## Key Mutations
113
-
114
- **Create a build:**
115
-
116
- ```graphql
117
- mutation {
118
- buildCreate(input: {
119
- pipelineID: "UGlwZWxpbmUtLS0..."
120
- commit: "HEAD"
121
- branch: "main"
122
- message: "Triggered via GraphQL"
123
- env: ["DEPLOY_TARGET=staging"]
124
- }) {
125
- build {
126
- number
127
- url
128
- state
129
- }
130
- }
131
- }
132
- ```
133
-
134
- Note: `pipelineID` is the GraphQL node ID (base64-encoded), not the pipeline slug. Retrieve it with a pipeline query first.
135
-
136
- **Create a pipeline** (use `clusterId` to associate with a cluster):
137
-
138
- ```graphql
139
- mutation {
140
- pipelineCreate(input: {
141
- organizationId: "T3JnYW5pemF0aW9uLS0t..."
142
- clusterId: "Q2x1c3Rlci0tLQ..."
143
- name: "My New Pipeline"
144
- repository: { url: "git@github.com:my-org/my-repo.git" }
145
- steps: { yaml: "steps:\n - label: ':test_tube: Test'\n command: 'make test'" }
146
- defaultBranch: "main"
147
- }) {
148
- pipeline {
149
- slug
150
- url
151
- }
152
- }
153
- }
154
- ```
155
-
156
- **Create a cluster queue:**
157
-
158
- ```graphql
159
- mutation {
160
- clusterQueueCreate(input: {
161
- organizationId: "T3JnYW5pemF0aW9uLS0t..."
162
- clusterId: "Q2x1c3Rlci0tLQ..."
163
- key: "linux-large"
164
- description: "Large Linux instances for monorepo builds"
165
- }) {
166
- clusterQueue {
167
- id
168
- key
169
- description
170
- }
171
- }
172
- }
173
- ```
174
-
175
- > For detailed guidance on cluster and queue provisioning strategy, see the **buildkite-agent-infrastructure** skill.
176
-
177
- Other key mutations: `pipelineUpdate`, `pipelineTemplateCreate` (Enterprise), `agentTokenCreate`, `agentTokenRevoke`.
178
-
179
- ## REST vs GraphQL Decision Guide
180
-
181
- | Scenario | Use | Why |
182
- |----------|-----|-----|
183
- | Trigger a build | Either | Both support it; REST is simpler |
184
- | List builds with filtering | REST | Better query parameter support |
185
- | Fetch build + jobs + artifacts in one call | GraphQL | Single request, no N+1 |
186
- | Create or update cluster queues | GraphQL | Not available in REST |
187
- | Create pipeline templates | GraphQL | Not available in REST |
188
- | Manage agent tokens | GraphQL | More control than REST |
189
- | Simple CRUD on pipelines | REST | Simpler request/response |
190
- | Audit events | GraphQL | `auditEvent` query available |
191
- | Bulk operations on many pipelines | GraphQL | Fetch specific fields only, reduce payload size |
192
-
193
- ## Introspection
194
-
195
- Use standard GraphQL introspection (`__schema`, `__type`) to discover available fields and types. The Buildkite GraphQL API supports full schema introspection.
@@ -1,44 +0,0 @@
1
- # API Usage Patterns
2
-
3
- ## Fetch All Failed Builds for a Pipeline
4
-
5
- ```bash
6
- #!/bin/bash
7
- # Fetch all failed builds from the last 24 hours
8
-
9
- org="my-org"
10
- pipeline="my-pipeline"
11
- since=$(date -u -d '24 hours ago' +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -v-24H +%Y-%m-%dT%H:%M:%SZ)
12
-
13
- curl -sS -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
14
- "https://api.buildkite.com/v2/organizations/$org/pipelines/$pipeline/builds?state=failed&created_from=$since&per_page=100" \
15
- | jq '.[] | {number, branch, message, web_url}'
16
- ```
17
-
18
- ## Build Success Rate Dashboard
19
-
20
- ```bash
21
- curl -sS -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
22
- "https://api.buildkite.com/v2/organizations/my-org/pipelines/my-pipeline/builds?per_page=100&branch=main" \
23
- | jq '{
24
- total: length,
25
- passed: [.[] | select(.state == "passed")] | length,
26
- failed: [.[] | select(.state == "failed")] | length,
27
- pass_rate: (([.[] | select(.state == "passed")] | length) * 100.0 / length)
28
- }'
29
- ```
30
-
31
- ## Trigger Downstream Pipeline
32
-
33
- ```python
34
- import requests
35
-
36
- def trigger_downstream(api_token, org, pipeline, branch="main", env=None):
37
- response = requests.post(
38
- f"https://api.buildkite.com/v2/organizations/{org}/pipelines/{pipeline}/builds",
39
- headers={"Authorization": f"Bearer {api_token}", "Content-Type": "application/json"},
40
- json={"commit": "HEAD", "branch": branch, "message": "Triggered by upstream", "env": env or {}}
41
- )
42
- response.raise_for_status()
43
- return response.json()["number"], response.json()["web_url"]
44
- ```