Skip to content

Commit dd21d01

Browse files
authored
Merge branch 'main' into maxcold/watermark-last-seen
2 parents 81b52ee + bdcf2c9 commit dd21d01

1,725 files changed

Lines changed: 28062 additions & 10068 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
name: buildkite-logs
3+
description: >-
4+
Fetch and analyse Buildkite CI logs for the elastic/kibana repo. Provides
5+
helpers to retrieve build/job logs by build number or PR number, summarise
6+
failures, and inspect artifacts. Use when the user asks about CI failures,
7+
Buildkite logs, a failing build, a red CI, build artifacts, or mentions a
8+
Buildkite URL or PR number in the context of CI.
9+
---
10+
11+
# Buildkite Logs
12+
13+
## Authentication
14+
15+
All requests require `BUILDKITE_API_TOKEN`. The token is read-only for most
16+
operations; a read-write token is needed to trigger retries.
17+
18+
```bash
19+
# Check for token
20+
if [ -z "$BUILDKITE_API_TOKEN" ]; then
21+
echo "Set BUILDKITE_API_TOKEN before proceeding."
22+
exit 1
23+
fi
24+
BK_AUTH="Authorization: Bearer $BUILDKITE_API_TOKEN"
25+
ORG="elastic"
26+
PIPELINE="kibana-pull-request"
27+
BASE="https://api.buildkite.com/v2"
28+
```
29+
30+
If the token is missing, ask the user to export it:
31+
> You can create a token at https://buildkite.com/user/api-access-tokens (scope: read_builds, read_artifacts).
32+
33+
---
34+
35+
## Fetch build by number
36+
37+
```bash
38+
BUILD_NUMBER=<number>
39+
curl -sf -H "$BK_AUTH" \
40+
"$BASE/organizations/$ORG/pipelines/$PIPELINE/builds/$BUILD_NUMBER" \
41+
| jq '{number,state,branch,commit,created_at,web_url,jobs:[.jobs[]|{id,name,state,exit_status,web_url}]}'
42+
```
43+
44+
To get a build number from a Buildkite URL like
45+
`https://buildkite.com/elastic/kibana-pull-request/builds/414685`, extract `414685`.
46+
47+
---
48+
49+
## Fetch latest build for a PR
50+
51+
```bash
52+
PR=<number>
53+
curl -sf -H "$BK_AUTH" \
54+
"$BASE/organizations/$ORG/pipelines/$PIPELINE/builds?pull_request_id=$PR&per_page=1" \
55+
| jq '.[0] | {number,state,branch,web_url,jobs:[.jobs[]|{id,name,state,exit_status}]}'
56+
```
57+
58+
---
59+
60+
## Fetch job log
61+
62+
Once you have a build number and job ID:
63+
64+
```bash
65+
BUILD_NUMBER=<number>
66+
JOB_ID=<uuid>
67+
curl -sf -H "$BK_AUTH" \
68+
"$BASE/organizations/$ORG/pipelines/$PIPELINE/builds/$BUILD_NUMBER/jobs/$JOB_ID/log" \
69+
| jq -r '.content'
70+
```
71+
72+
Logs can be large. Pipe through `tail -n 200` or search with `grep`/`rg` for
73+
relevant sections:
74+
75+
```bash
76+
... | jq -r '.content' | grep -A 5 -i "error\|fail\|FAIL\|exception"
77+
```
78+
79+
---
80+
81+
## Workflow: diagnose a failing build
82+
83+
1. **Get build overview** (fetch build by number or PR, see above).
84+
2. **Identify failed jobs**: filter `jobs` where `state == "failed"`.
85+
3. **Fetch log for each failed job** and search for the first error/failure.
86+
4. **Summarise**: report job name, exit code, and the key error lines.
87+
88+
For large logs, focus on the last 200–500 lines plus any lines matching
89+
`error`, `FAIL`, `AssertionError`, `TypeError`, or ``.
90+
91+
---
92+
93+
## Workflow: understand job definition for PR build
94+
1. Analyse .buildkite/pipelines/pull_request/base.yml
95+
2. Analyse any relevant yml files in the folder
96+
97+
## List and download artifacts
98+
99+
```bash
100+
BUILD_NUMBER=<number>
101+
# List artifacts for the build
102+
curl -sf -H "$BK_AUTH" \
103+
"$BASE/organizations/$ORG/pipelines/$PIPELINE/builds/$BUILD_NUMBER/artifacts" \
104+
| jq '.[] | {id,filename,file_size,download_url}'
105+
106+
# Download a specific artifact
107+
ARTIFACT_ID=<uuid>
108+
curl -sL -H "$BK_AUTH" \
109+
"$BASE/organizations/$ORG/pipelines/$PIPELINE/builds/$BUILD_NUMBER/artifacts/$ARTIFACT_ID/download" \
110+
-o <filename>
111+
```
112+
113+
Artifacts for a single job:
114+
```bash
115+
JOB_ID=<uuid>
116+
curl -sf -H "$BK_AUTH" \
117+
"$BASE/organizations/$ORG/pipelines/$PIPELINE/builds/$BUILD_NUMBER/jobs/$JOB_ID/artifacts" \
118+
| jq '.[] | {id,filename,file_size,download_url}'
119+
```
120+
121+
---
122+
123+
## Other pipelines
124+
125+
Kibana has multiple pipelines. Common slugs:
126+
127+
| Pipeline | Slug |
128+
|---|---|
129+
| PR | `kibana-pull-request` |
130+
| On-merge | `kibana-on-merge` |
131+
| Flaky test runner | `kibana-flaky-test-suite-runner` |
132+
133+
Substitute the `PIPELINE` variable as needed.

0 commit comments

Comments
 (0)