系统学习 DevOps 学习路径:从版本控制到可观测与供应链

buildkite

Buildkite CI 流水线

补充说明

Buildkite 由托管控制面和自建 agent 组成,流水线用 YAML 定义,构建在自有基础设施上执行。适合需要自定义构建环境、GPU 或内网访问的团队。

核心概念:pipeline、step、agent、queue、plugin、hook。

常用示例

安装 agent:

curl -fsSL https://buildkite.com/install | bash
buildkite-agent start --token "$BUILDKITE_AGENT_TOKEN"

pipeline.yml:

steps:
- label: ":test_tube: test"
  command: "make test"
  agents:
    queue: "linux"
- label: ":docker: build"
  command: "docker build -t app:$BUILDKITE_COMMIT ."
  depends_on: test
- wait
- label: ":rocket: deploy"
  command: "./deploy.sh"
  if: build.branch == "main"

动态流水线:

buildkite-agent pipeline upload .buildkite/deploy.yml

易错点与排错

相关命令

参考链接

读完自测

合上页面,先回答,再展开对照。

  1. 某个 step 一直处于等待状态,常见原因是什么?
  2. 为什么部署 step 可能先于测试执行?怎么避免?
  3. Buildkite agent token 泄露有什么后果?
答案
  1. queue 名称与 agent 的队列不匹配,step 会一直等待。
  2. 没有设置 depends_on;应显式声明依赖关系,确保部署在测试之后执行。
  3. 任何人都能注册 agent,向流水线注入不可信的执行节点,必须妥善管理。
微信小程序码:扫码打开命令速查小程序

小程序版

微信扫码,随时查命令