Agent Skillsray-project/ray › fetch-buildkite-logs

fetch-buildkite-logs

GitHub

从 Buildkite 获取 CI 构建日志及制品,解析失败任务并总结错误原因,辅助排查构建问题。

.claude/skills/fetch-buildkite-logs/SKILL.md ray-project/ray

触发场景

用户询问构建失败原因 需要分析特定构建或作业的日志

安装

npx skills add ray-project/ray --skill fetch-buildkite-logs -g -y
更多选项

非标准路径

npx skills add https://github.com/ray-project/ray/tree/master/.claude/skills/fetch-buildkite-logs -g -y

不安装直接使用

npx skills use ray-project/ray@fetch-buildkite-logs

指定 Agent (Claude Code)

npx skills add ray-project/ray --skill fetch-buildkite-logs -a claude-code -g -y

安装 repo 全部 skill

npx skills add ray-project/ray --all -g -y

预览 repo 内 skill

npx skills add ray-project/ray --list

SKILL.md

Frontmatter
{
    "name": "fetch-buildkite-logs",
    "description": "Fetch Buildkite CI job logs, and a job's artifacts when the logs are not enough, from a Buildkite build URL or build number, then summarize the failures"
}

Fetch Buildkite Logs

Prerequisites

  • BUILDKITE_API_TOKEN must be set in the environment (typically ~/.bashrc)
  • If not configured, direct user to doc/source/ray-contribute/agent-development.md for setup

Parsing the Buildkite URL

A Buildkite URL has the form:

https://buildkite.com/ray-project/<PIPELINE>/builds/<BUILD_NUM>#<JOB_ID>

Always extract <PIPELINE> (e.g. premerge, postmerge) and <BUILD_NUM> from the URL the user provides. Do not hardcode premerge — the same skill is used for all pipelines. If a #<JOB_ID> fragment is present, it identifies a specific real job (not a group/wait job) and can be queried directly.

Steps

  1. Verify token: [ -n "$BUILDKITE_API_TOKEN" ] && echo "token set" || echo "token MISSING" (do not echo the token itself — a command that prints secret characters gets blocked)
  2. If token missing, stop and show setup instructions from the dev docs
  3. Fetch build (use the pipeline from the URL):
    curl -s -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
      "https://api.buildkite.com/v2/organizations/ray-project/pipelines/<PIPELINE>/builds/<BUILD_NUM>"
    
  4. If a job ID is present in the URL fragment, look it up directly:
    curl -s -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
      "https://api.buildkite.com/v2/organizations/ray-project/pipelines/<PIPELINE>/builds/<BUILD_NUM>" \
      | python3 -c "import sys,json; jobs=json.load(sys.stdin)['jobs']; [print(f\"{j['id']} {j.get('name')} -> {j.get('state')}\") for j in jobs if j['id']=='<JOB_ID>']"
    
  5. Otherwise list failed/broken jobs:
    curl -s -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
      "https://api.buildkite.com/v2/organizations/ray-project/pipelines/<PIPELINE>/builds/<BUILD_NUM>" \
      | python3 -c "import sys,json; jobs=json.load(sys.stdin)['jobs']; [print(f\"{j['id']} {j.get('name')} -> {j['state']}\") for j in jobs if j.get('state') in ('failed','broken')]"
    
  6. Fetch individual job log:
    curl -s -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
      "https://api.buildkite.com/v2/organizations/ray-project/pipelines/<PIPELINE>/builds/<BUILD_NUM>/jobs/<JOB_ID>/log" \
      > /tmp/log_<JOB_ID>.json
    
    Logs come back as JSON with a content field containing ANSI escape codes — strip them with re.sub(r'\x1b\[[0-9;]*m', '', content) before grepping.
  7. Summarize failures and suggest fixes.

Artifacts

If the log does not let you identify the root cause, look for more logs in the job's artifacts.

The token needs the read_artifacts scope in addition to read_build_logs; without it these calls return HTTP 403.

  1. List a job's artifacts (raise page if a full page of 100 comes back):
    curl -s -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
      "https://api.buildkite.com/v2/organizations/ray-project/pipelines/<PIPELINE>/builds/<BUILD_NUM>/jobs/<JOB_ID>/artifacts?per_page=100&page=1"
    
  2. Download one by its id:
    curl -fsL -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
      "https://api.buildkite.com/v2/organizations/ray-project/pipelines/<PIPELINE>/builds/<BUILD_NUM>/jobs/<JOB_ID>/artifacts/<ARTIFACT_ID>/download" \
      -o /tmp/<ARTIFACT_ID>
    
    -L is required: the endpoint returns HTTP 302 and redirects to S3. Keep the Authorization header — curl drops it on the cross-host hop, which is what S3 wants (sending it yields 400 InvalidRequest).
  3. If the artifact is a zip, unzip it — the logs are inside. If that is still not enough, try another artifact.

Authentication note

If curl returns {"message":"No organization found"}, the configured token does not have access to ray-project. The user may have a separate org-scoped token — ask them which env var to source.

版本历史

  • 7bbef5a 当前 2026-08-28 16:15

    新增下载作业工件的功能,以在日志信息不足时辅助故障排查。

  • 3fb63d9 2026-07-25 11:18

同 Skill 集合

.claude/skills/backport-docs/SKILL.md
.claude/skills/ray-dependencies/SKILL.md
.claude/skills/rebuild/SKILL.md
doc/.claude/skills/ray-soft-wrap/SKILL.md
.claude/skills/lint/SKILL.md
doc/.claude/skills/rst-to-myst/SKILL.md
doc/.claude/skills/sphinx-fix/SKILL.md

元信息

文件数
0
版本
0dc4886
Hash
0bbca687
收录时间
2026-07-25 11:18

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-17 20:09
浙ICP备14020137号-1