buildkite-agent-runtime
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBuildkite Agent Runtime
Buildkite Agent 运行时
The binary provides subcommands for interacting with Buildkite from within running job steps — creating annotations, uploading artifacts, sharing state between jobs, generating dynamic pipelines, requesting OIDC tokens, and more. This skill covers the command syntax, flags, and patterns for every in-job subcommand.
buildkite-agentbuildkite-agentQuick Start
快速入门
A step that runs tests, annotates failures, uploads coverage, and stores a result flag for downstream jobs:
yaml
steps:
- label: ":test_tube: Tests"
command: |
if ! make test 2>&1 | tee test-output.txt; then
buildkite-agent annotate --style "error" --context "test-failures" < test-output.txt
buildkite-agent meta-data set "tests-passed" "false"
exit 1
fi
buildkite-agent annotate "All tests passed :white_check_mark:" --style "success" --context "test-results"
buildkite-agent artifact upload "coverage/**/*"
buildkite-agent meta-data set "tests-passed" "true"A downstream step reading that state:
yaml
- label: ":rocket: Deploy"
command: |
PASSED=$(buildkite-agent meta-data get "tests-passed")
if [[ "$PASSED" != "true" ]]; then
echo "Tests did not pass, skipping deploy"
exit 0
fi
scripts/deploy.sh
depends_on: "test-step"一个运行测试、标记失败、上传覆盖率并为下游作业存储结果标志的步骤:
yaml
steps:
- label: ":test_tube: Tests"
command: |
if ! make test 2>&1 | tee test-output.txt; then
buildkite-agent annotate --style "error" --context "test-failures" < test-output.txt
buildkite-agent meta-data set "tests-passed" "false"
exit 1
fi
buildkite-agent annotate "All tests passed :white_check_mark:" --style "success" --context "test-results"
buildkite-agent artifact upload "coverage/**/*"
buildkite-agent meta-data set "tests-passed" "true"读取该状态的下游步骤:
yaml
- label: ":rocket: Deploy"
command: |
PASSED=$(buildkite-agent meta-data get "tests-passed")
if [[ "$PASSED" != "true" ]]; then
echo "Tests did not pass, skipping deploy"
exit 0
fi
scripts/deploy.sh
depends_on: "test-step"Annotations
注释
Surface build results directly on the build page. Annotations support Markdown and HTML.
在构建页面直接展示构建结果。注释支持Markdown和HTML格式。
Creating annotations
创建注释
bash
undefinedbash
undefinedSimple text annotation
简单文本注释
buildkite-agent annotate "Deploy completed successfully" --style "success" --context "deploy"
buildkite-agent annotate "Deploy completed successfully" --style "success" --context "deploy"
Pipe from a file
从文件导入内容
buildkite-agent annotate --style "error" --context "test-failures" < test-output.md
undefinedbuildkite-agent annotate --style "error" --context "test-failures" < test-output.md
undefinedKey flags
关键标志
| Flag | Short | Default | Description |
|---|---|---|---|
| | | Visual style: |
| | random UUID | Unique ID — reusing a context replaces the annotation |
| — | | Append to existing annotation with same context instead of replacing |
| — | | Display priority (1-10). Higher numbers appear first |
| — | current job | Job ID to annotate (rarely needed) |
| 标志 | 简写 | 默认值 | 描述 |
|---|---|---|---|
| | | 视觉样式: |
| | 随机UUID | 唯一ID——重复使用相同context会替换原注释 |
| — | | 向具有相同context的现有注释追加内容,而非替换 |
| — | | 显示优先级(1-10),数值越高越靠前显示 |
| — | 当前作业 | 要添加注释的作业ID(很少需要) |
Replacing vs appending
替换与追加
- Same without
--contextreplaces the annotation; with--appendappends below existing content.--append - Always use a stable value so reruns update the same annotation instead of creating duplicates.
--context
For pipeline-levelconfiguration, see the buildkite-pipelines skill.notify:
- **相同且不带
--context**会替换注释;**带--append**会在现有内容下方追加。--append - 始终使用稳定的值,以便重新运行时更新同一注释,而非创建重复项。
--context
关于流水线级别的配置,请查看buildkite-pipelines技能。notify:
Artifacts
工件
Upload files as build artifacts, download them in later steps or other builds, and search by glob.
将文件上传为构建工件,可在后续步骤或其他构建中下载,也可通过通配符搜索。
Upload
上传
bash
undefinedbash
undefinedUpload a single file
上传单个文件
buildkite-agent artifact upload "pkg/release.tar.gz"
buildkite-agent artifact upload "pkg/release.tar.gz"
Upload with glob pattern
使用通配符模式上传
buildkite-agent artifact upload "dist/**/*"
undefinedbuildkite-agent artifact upload "dist/**/*"
undefinedDownload
下载
bash
undefinedbash
undefinedDownload to current directory
下载到当前目录
buildkite-agent artifact download "pkg/release.tar.gz" .
buildkite-agent artifact download "pkg/release.tar.gz" .
Download from a specific step
从指定步骤下载
buildkite-agent artifact download "dist/*" . --step "build-step"
undefinedbuildkite-agent artifact download "dist/*" . --step "build-step"
undefinedSearch
搜索
bash
undefinedbash
undefinedList matching artifacts
列出匹配的工件
buildkite-agent artifact search "pkg/*.tar.gz" --build "$BUILDKITE_BUILD_ID"
For complete flag tables, see `references/flag-reference.md`.
> For the declarative `artifact_paths:` YAML key, see the **buildkite-pipelines** skill. For `bk artifact` CLI commands, see the **buildkite-cli** skill.buildkite-agent artifact search "pkg/*.tar.gz" --build "$BUILDKITE_BUILD_ID"
完整的标志表格请查看`references/flag-reference.md`。
> 关于声明式`artifact_paths:` YAML键,请查看**buildkite-pipelines**技能。关于`bk artifact` CLI命令,请查看**buildkite-cli**技能。Meta-data
元数据
A build-wide key-value store for sharing state between jobs. Set a value in one job, read it in any other job in the same build.
构建级别的键值存储,用于在作业间共享状态。在一个作业中设置值,可在同一构建的任何其他作业中读取。
Set
设置
bash
buildkite-agent meta-data set "release-version" "1.4.2"bash
buildkite-agent meta-data set "release-version" "1.4.2"Get
获取
bash
VERSION=$(buildkite-agent meta-data get "release-version")Use to return a fallback value instead of a non-zero exit when the key is missing: .
--defaultbuildkite-agent meta-data get "deploy-env" --default "staging"bash
VERSION=$(buildkite-agent meta-data get "release-version")使用可在键不存在时返回回退值,而非返回非零退出码:。
--defaultbuildkite-agent meta-data get "deploy-env" --default "staging"Check existence
检查存在性
bash
undefinedbash
undefinedReturns exit code 0 if exists, 100 if not
若存在返回退出码0,不存在返回100
if buildkite-agent meta-data exists "release-version"; then
echo "Version already set"
fi
undefinedif buildkite-agent meta-data exists "release-version"; then
echo "Version already set"
fi
undefinedCommon patterns
常见模式
Block step field values are stored automatically as meta-data. Retrieve them by field key:
bash
undefined阻塞步骤字段值会自动存储为元数据。可通过字段键检索:
bash
undefinedAfter a block step with fields: [{key: "release-name", text: "Release Name"}]
在包含字段的阻塞步骤之后:[{key: "release-name", text: "Release Name"}]
RELEASE_NAME=$(buildkite-agent meta-data get "release-name")
**Raw webhook payloads** are available in webhook-triggered builds, while the webhook data remains cached. Read the special `buildkite:webhook` key when automation needs fields that are not promoted to first-class environment variables, such as the original pull request comment body.
```bash
WEBHOOK="$(buildkite-agent meta-data get "buildkite:webhook")"
COMMENT_BODY="$(jq -r '.comment.body' <<< "$WEBHOOK")"RELEASE_NAME=$(buildkite-agent meta-data get "release-name")
**原始webhook负载**在webhook触发的构建中可用,同时webhook数据会被缓存。当自动化需要未提升为一级环境变量的字段(如原始拉取请求评论内容)时,读取特殊的`buildkite:webhook`键。
```bash
WEBHOOK="$(buildkite-agent meta-data get "buildkite:webhook")"
COMMENT_BODY="$(jq -r '.comment.body' <<< "$WEBHOOK")"Pipeline Upload
流水线上传
Dynamically add steps to a running build. The core mechanism behind dynamic pipelines — generate YAML at runtime and upload it.
向运行中的构建动态添加步骤。这是动态流水线的核心机制——在运行时生成YAML并上传。
Basic usage
基本用法
bash
undefinedbash
undefinedUpload a specific file
上传指定文件
buildkite-agent pipeline upload .buildkite/deploy-steps.yml
buildkite-agent pipeline upload .buildkite/deploy-steps.yml
Pipe generated YAML from stdin
从标准输入导入生成的YAML
./scripts/generate-pipeline.sh | buildkite-agent pipeline upload
undefined./scripts/generate-pipeline.sh | buildkite-agent pipeline upload
undefinedReplace mode
替换模式
By default, uploaded steps are appended after the current step. Use to replace the entire remaining pipeline:
--replacebash
undefined默认情况下,上传的步骤会追加到当前步骤之后。使用可替换整个剩余流水线:
--replacebash
undefinedReplace all remaining steps with the uploaded ones
用上传的步骤替换所有剩余步骤
buildkite-agent pipeline upload --replace .buildkite/new-pipeline.yml
undefinedbuildkite-agent pipeline upload --replace .buildkite/new-pipeline.yml
undefinedKey flags
关键标志
| Flag | Default | Description |
|---|---|---|
| | Replace remaining pipeline steps instead of appending |
| | Skip environment variable interpolation in the uploaded YAML |
| | Validate and output the pipeline without uploading |
For pipeline YAML syntax and step types, see the buildkite-pipelines skill.
| 标志 | 默认值 | 描述 |
|---|---|---|
| | 替换剩余流水线步骤,而非追加 |
| | 跳过上传YAML中的环境变量插值 |
| | 验证并输出流水线,但不上传 |
关于流水线YAML语法和步骤类型,请查看buildkite-pipelines技能。
OIDC Tokens
OIDC令牌
Request short-lived OpenID Connect tokens from within a job step for authenticating to external services (cloud providers, package registries) without static credentials.
在作业步骤内请求短期OpenID Connect令牌,用于向外部服务(云提供商、包注册表)认证,无需静态凭据。
Basic token request
基本令牌请求
bash
undefinedbash
undefinedRequest a token for a specific audience
请求针对特定受众的令牌
TOKEN=$(buildkite-agent oidc request-token --audience "https://packages.buildkite.com/my-org/my-registry")
undefinedTOKEN=$(buildkite-agent oidc request-token --audience "https://packages.buildkite.com/my-org/my-registry")
undefinedCloud provider authentication
云提供商认证
bash
undefinedbash
undefinedAWS — request token with STS audience
AWS — 请求带有STS受众的令牌
TOKEN=$(buildkite-agent oidc request-token --audience "sts.amazonaws.com")
undefinedTOKEN=$(buildkite-agent oidc request-token --audience "sts.amazonaws.com")
undefinedKey flags
关键标志
| Flag | Default | Description |
|---|---|---|
| Buildkite endpoint | Target service URL — must match the OIDC provider audience configuration |
| | Token lifetime in seconds. When 0 or omitted, the API chooses a default lifetime |
| — | Optional claims to include (e.g., |
| — | Claims to map as AWS session tags. Repeatable |
For end-to-end OIDC auth flows, cloud provider setup, and token claim details, see the buildkite-secure-delivery skill.
| 标志 | 默认值 | 描述 |
|---|---|---|
| Buildkite端点 | 目标服务URL——必须与OIDC提供商的受众配置匹配 |
| | 令牌有效期(秒)。设为0或省略时,由API选择默认有效期 |
| — | 可选要包含的声明(如 |
| — | 要映射为AWS会话标签的声明,可重复使用 |
关于端到端OIDC认证流程、云提供商设置和令牌声明详情,请查看buildkite-secure-delivery技能。
Step Management
步骤管理
Read or modify step attributes at runtime. Useful for conditional logic within steps and build automation.
在运行时读取或修改步骤属性,适用于步骤内的条件逻辑和构建自动化。
Get step attributes
获取步骤属性
bash
undefinedbash
undefinedGet a step's label (--step is required)
获取步骤的标签(必须指定--step)
LABEL=$(buildkite-agent step get "label" --step "$BUILDKITE_STEP_KEY")
LABEL=$(buildkite-agent step get "label" --step "$BUILDKITE_STEP_KEY")
Get another step's state
获取另一个步骤的状态
STATE=$(buildkite-agent step get "state" --step "deploy-step")
STATE=$(buildkite-agent step get "state" --step "deploy-step")
Get the entire step as JSON
以JSON格式获取整个步骤的信息
buildkite-agent step get --step "test-step" --format json
undefinedbuildkite-agent step get --step "test-step" --format json
undefinedUpdate step attributes
更新步骤属性
bash
undefinedbash
undefinedUpdate a step's label dynamically
动态更新步骤的标签
buildkite-agent step update "label" ":rocket: Deploying v${VERSION}" --step "$BUILDKITE_STEP_KEY"
buildkite-agent step update "label" ":rocket: Deploying v${VERSION}" --step "$BUILDKITE_STEP_KEY"
Append to an existing label
向现有标签追加内容
buildkite-agent step update "label" " (retried)" --step "build-step" --append
undefinedbuildkite-agent step update "label" " (retried)" --step "build-step" --append
undefinedCancel a step
取消步骤
bash
undefinedbash
undefinedCancel all unfinished jobs for a step
取消某一步骤的所有未完成作业
buildkite-agent step cancel --step "optional-step"
buildkite-agent step cancel --step "optional-step"
Force-cancel a running step
强制取消正在运行的步骤
buildkite-agent step cancel --step "stuck-step" --force
undefinedbuildkite-agent step cancel --step "stuck-step" --force
undefinedKey flags
关键标志
| Flag | Default | Description |
|---|---|---|
| — | Step key or UUID to target (required — uses |
| current build | Build UUID (for cross-build operations) |
| — | Output format for |
| | Append to existing value instead of replacing ( |
| | Force cancel even if the step is running ( |
| 标志 | 默认值 | 描述 |
|---|---|---|
| — | 目标步骤的键或UUID(必填——若设置了 |
| 当前构建 | 构建UUID(用于跨构建操作) |
| — | |
| | 向现有值追加内容而非替换(仅 |
| | 即使步骤正在运行也强制取消(仅 |
Distributed Locks
分布式锁
Coordinate parallel jobs within a build using distributed mutex locks. Prevents race conditions when multiple jobs access shared resources.
使用分布式互斥锁协调构建中的并行作业,防止多个作业访问共享资源时出现竞争条件。
Acquire / release pattern
获取/释放模式
bash
#!/bin/bash
set -euo pipefailbash
#!/bin/bash
set -euo pipefailAcquire lock — blocks until available, returns a token
获取锁——阻塞直到可用,返回令牌
token=$(buildkite-agent lock acquire "database-migration")
trap 'buildkite-agent lock release "database-migration" "${token}"' EXIT
token=$(buildkite-agent lock acquire "database-migration")
trap 'buildkite-agent lock release "database-migration" "${token}"' EXIT
Critical section — only one job runs this at a time
临界区——同一时间只有一个作业运行此部分代码
bundle exec rails db:migrate
undefinedbundle exec rails db:migrate
undefinedDo / done pattern (one-time setup)
Do/Done模式(一次性设置)
Run a setup task exactly once across all parallel jobs:
bash
#!/bin/bash
echo "+++ Setting up shared test environment"
if [[ $(buildkite-agent lock do "test-env-setup") == "do" ]]; then
echo "Downloading test assets..."
curl -o /tmp/test-data.zip https://releases.example.com/data.zip
unzip /tmp/test-data.zip -d /tmp/shared-test-files/
buildkite-agent lock done "test-env-setup"
else
echo "Assets already prepared by another job"
fi在所有并行作业中仅运行一次设置任务:
bash
#!/bin/bash
echo "+++ Setting up shared test environment"
if [[ $(buildkite-agent lock do "test-env-setup") == "do" ]]; then
echo "Downloading test assets..."
curl -o /tmp/test-data.zip https://releases.example.com/data.zip
unzip /tmp/test-data.zip -d /tmp/shared-test-files/
buildkite-agent lock done "test-env-setup"
else
echo "Assets already prepared by another job"
fiAll jobs continue here
所有作业在此处继续执行
run-tests.sh
undefinedrun-tests.sh
undefinedKey flags
关键标志
| Subcommand | Flags | Description |
|---|---|---|
| | Maximum wait duration (e.g. |
| — | Release with the token from |
| — | Returns |
| — | Mark a |
| 子命令 | 标志 | 描述 |
|---|---|---|
| | 最大等待时长(如 |
| — | 使用 |
| — | 获取锁则返回 |
| — | 将 |
Environment
环境变量
Inspect and modify the job's environment variables. Primarily useful for debugging lifecycle hooks and understanding what environment changes hooks made.
bash
undefined检查和修改作业的环境变量,主要用于调试生命周期钩子,以及了解钩子对环境的修改。
bash
undefinedDump all environment variables as JSON
以JSON格式导出所有环境变量
buildkite-agent env dump | jq .
buildkite-agent env dump | jq .
Get a specific variable
获取特定变量
buildkite-agent env get "BUILDKITE_BRANCH"
buildkite-agent env get "BUILDKITE_BRANCH"
Set variables for subsequent hooks and the command (KEY=value format)
为后续钩子和命令设置变量(KEY=value格式)
buildkite-agent env set DEPLOY_TARGET=production "APP_NAME=My App"
undefinedbuildkite-agent env set DEPLOY_TARGET=production "APP_NAME=My App"
undefinedKey flags
关键子命令
| Subcommand | Description |
|---|---|
| Dump all environment variables (JSON format by default) |
| Get one or more specific variables. Use |
| Set variables for subsequent phases. Accepts multiple |
| Remove a variable from subsequent phases |
| 子命令 | 描述 |
|---|---|
| 导出所有环境变量(默认JSON格式) |
| 获取一个或多个特定变量,使用 |
| 为后续阶段设置变量,支持多个 |
| 从后续阶段移除变量 |
Debugging hooks
调试钩子
The command is particularly useful in lifecycle hooks to see what prior hooks changed:
env dumpbash
#!/bin/bashenv dumpbash
#!/bin/bash.buildkite/hooks/pre-command
.buildkite/hooks/pre-command
echo "--- Environment after environment hook:"
buildkite-agent env dump | jq 'keys'
> For agent lifecycle hooks and `buildkite-agent.cfg` configuration, see the [agent hooks](https://buildkite.com/docs/agent/hooks) and [agent configuration](https://buildkite.com/docs/agent/self-hosted/configure) documentation.echo "--- Environment after environment hook:"
buildkite-agent env dump | jq 'keys'
> 关于Agent生命周期钩子和`buildkite-agent.cfg`配置,请查看[Agent钩子](https://buildkite.com/docs/agent/hooks)和[Agent配置](https://buildkite.com/docs/agent/self-hosted/configure)文档。Secrets
机密
Retrieve cluster secrets at runtime from within job steps. Secrets retrieved this way are automatically added to the log redactor.
在运行时从作业步骤中检索集群机密,以此方式检索的机密会自动添加到日志编辑器中。
Basic usage
基本用法
bash
undefinedbash
undefinedGet a secret value
获取机密值
SECRET_VAR=$(buildkite-agent secret get "deploy-key")
SECRET_VAR=$(buildkite-agent secret get "deploy-key")
Pass directly to a tool
直接传递给工具
cli-tool --token "$(buildkite-agent secret get "api-token")"
undefinedcli-tool --token "$(buildkite-agent secret get "api-token")"
undefinedKey flags
关键标志
| Flag | Default | Description |
|---|---|---|
| | Output format: |
| | Do not add the secret value to the log redactor |
| current job | Job ID context |
Multiple secret keys can be requested at once: .
buildkite-agent secret get KEY1 KEY2 KEY3By default, automatically registers retrieved values with the log redactor, masking them as in subsequent output.
secret get[REDACTED]For setting up cluster secrets, see the Buildkite Secrets documentation. For the declarativepipeline YAML key, see the buildkite-pipelines skill.secrets:
| 标志 | 默认值 | 描述 |
|---|---|---|
| | 输出格式: |
| | 不将机密值添加到日志编辑器 |
| 当前作业 | 作业ID上下文 |
可同时请求多个机密键:。
buildkite-agent secret get KEY1 KEY2 KEY3默认情况下,会自动将检索到的值注册到日志编辑器中,在后续输出中会将其屏蔽为。
secret get[REDACTED]关于集群机密的设置,请查看Buildkite Secrets文档。关于声明式流水线YAML键,请查看buildkite-pipelines技能。secrets:
Log Redaction
日志编辑
Add values to the build log redactor at runtime so they are masked in all subsequent output. Use this for dynamically-retrieved secrets that were not declared via or .
secrets:buildkite-agent secret get在运行时将值添加到构建日志编辑器中,使其在所有后续输出中被屏蔽。适用于未通过或声明的动态检索机密。
secrets:buildkite-agent secret getBasic usage
基本用法
bash
undefinedbash
undefinedFetch a token from an external source
从外部源获取令牌
DYNAMIC_TOKEN=$(curl -s https://vault.example.com/token)
DYNAMIC_TOKEN=$(curl -s https://vault.example.com/token)
Register it with the redactor before using it
在使用前将其注册到编辑器
echo "$DYNAMIC_TOKEN" | buildkite-agent redactor add
echo "$DYNAMIC_TOKEN" | buildkite-agent redactor add
Now any log output containing the token value shows [REDACTED]
现在任何包含令牌值的日志输出都会显示为[REDACTED]
echo "Using token: $DYNAMIC_TOKEN"
echo "Using token: $DYNAMIC_TOKEN"
Output: Using token: [REDACTED]
输出:Using token: [REDACTED]
undefinedundefinedMultiple values
多个值
bash
undefinedbash
undefinedRedact multiple values
屏蔽多个值
echo "$SECRET1" | buildkite-agent redactor add
echo "$SECRET2" | buildkite-agent redactor add
undefinedecho "$SECRET1" | buildkite-agent redactor add
echo "$SECRET2" | buildkite-agent redactor add
undefinedWhen to use redactor vs secret get
使用编辑器还是secret get
| Scenario | Use |
|---|---|
| Secret stored in Buildkite cluster secrets | |
| Secret from external vault (HashiCorp Vault, AWS SSM, etc.) | Fetch externally, then |
| Computed sensitive value (temporary token, derived key) | |
| 场景 | 使用方式 |
|---|---|
| 存储在Buildkite集群机密中的机密 | |
| 来自外部Vault(HashiCorp Vault、AWS SSM等)的机密 | 从外部获取,然后使用 |
| 计算得出的敏感值(临时令牌、派生密钥) | |
Tool Signing
工具签名
Sign pipeline YAML so that agents can verify step integrity before execution. The command takes a pipeline file (not individual steps) and annotates it with signatures.
tool sign对流水线YAML进行签名,以便Agent在执行前验证步骤完整性。命令接收流水线文件(而非单个步骤),并为其添加签名注释。
tool signSign a pipeline from a file
对文件中的流水线签名
bash
undefinedbash
undefinedSign a pipeline YAML file using a local JWKS key
使用本地JWKS密钥对流水线YAML文件签名
buildkite-agent tool sign pipeline.yml
--jwks-file /path/to/private-key.json
--repo "git@github.com:org/repo.git"
--jwks-file /path/to/private-key.json
--repo "git@github.com:org/repo.git"
undefinedbuildkite-agent tool sign pipeline.yml
--jwks-file /path/to/private-key.json
--repo "git@github.com:org/repo.git"
--jwks-file /path/to/private-key.json
--repo "git@github.com:org/repo.git"
undefinedSign via the GraphQL API
通过GraphQL API签名
bash
undefinedbash
undefinedRetrieve, sign, and update a pipeline via the Buildkite GraphQL API
通过Buildkite GraphQL API检索、签名并更新流水线
buildkite-agent tool sign
--graphql-token "$BUILDKITE_GRAPHQL_TOKEN"
--organization-slug my-org
--pipeline-slug my-pipeline
--jwks-file /path/to/private-key.json
--update
--graphql-token "$BUILDKITE_GRAPHQL_TOKEN"
--organization-slug my-org
--pipeline-slug my-pipeline
--jwks-file /path/to/private-key.json
--update
undefinedbuildkite-agent tool sign
--graphql-token "$BUILDKITE_GRAPHQL_TOKEN"
--organization-slug my-org
--pipeline-slug my-pipeline
--jwks-file /path/to/private-key.json
--update
--graphql-token "$BUILDKITE_GRAPHQL_TOKEN"
--organization-slug my-org
--pipeline-slug my-pipeline
--jwks-file /path/to/private-key.json
--update
undefinedGenerate a signing key pair
生成签名密钥对
bash
undefinedbash
undefinedGenerate a new JWS key pair (private + public JWKS files)
生成新的JWS密钥对(私钥+公钥JWKS文件)
buildkite-agent tool keygen
undefinedbuildkite-agent tool keygen
undefinedKey flags
关键标志
| Command | Flag | Description |
|---|---|---|
| | Path to JWKS private key file for signing |
| | Key ID to use from the JWKS file |
| | Repository URL (required when signing from a file) |
| | AWS KMS key ID for signing (alternative to JWKS) |
| | GCP KMS key ID for signing (alternative to JWKS) |
| | Token for retrieving/updating pipeline via GraphQL API |
| | Update the pipeline in Buildkite after signing (requires |
| | JWS signing algorithm (default: |
| | Key ID for the generated pair (default: random) |
Note: There is nocommand. Signature verification is handled internally by the agent when it receives a job.tool verify
For pipeline signing configuration and rollout strategy, see the buildkite-secure-delivery skill.
| 命令 | 标志 | 描述 |
|---|---|---|
| | 用于签名的JWKS私钥文件路径 |
| | JWKS文件中要使用的密钥ID |
| | 仓库URL(对文件签名时必填) |
| | 用于签名的AWS KMS密钥ID(JWKS的替代方案) |
| | 用于签名的GCP KMS密钥ID(JWKS的替代方案) |
| | 通过GraphQL API检索/更新流水线的令牌 |
| | 签名后在Buildkite中更新流水线(需要 |
| | JWS签名算法(默认: |
| | 生成密钥对的ID(默认:随机值) |
注意: 没有命令。签名验证由Agent在接收作业时内部处理。tool verify
关于流水线签名配置和部署策略,请查看buildkite-secure-delivery技能。
Common Mistakes
常见错误
| Mistake | What happens | Fix |
|---|---|---|
Missing | Each call creates a new annotation instead of updating | Always pass |
Using | Append has no effect — creates a new annotation | Ensure |
| Forgetting to quote artifact glob patterns | Shell expands globs before | Always quote: |
Reading | Key does not exist, command fails with non-zero exit | Use |
Using | Removes all remaining steps in the build | Only use |
| Not releasing locks on script failure | Lock held indefinitely, blocking other jobs | Use |
Passing | Token rejected by the target service | Audience must exactly match the provider's configured audience URL |
Using | Secret values appear in plain text in build logs | Only use |
Calling | Variable is set for subsequent hooks/phases, not the current script | Use |
| Passing large values via environment variables | OS-level env size limits cause silent truncation or job failure | Switch to file-based approaches (artifacts, meta-data with files) for payloads larger than a few KB |
Uploading pipeline YAML with unescaped | Variables interpolated unexpectedly, producing malformed YAML | Use |
| 错误 | 后果 | 修复方案 |
|---|---|---|
| 每次调用都会创建新注释,而非更新 | 始终传递带有稳定标识符的 |
使用 | 追加无效,创建新注释 | 确保 |
| 忘记给工件通配符模式加引号 | Shell在 | 始终加引号: |
在写入作业完成前读取 | 键不存在,命令以非零退出码失败 | 使用 |
无意使用 | 移除构建中所有剩余步骤 | 仅在有意重建整个流水线时使用 |
| 脚本失败时未释放锁 | 锁被无限持有,阻塞其他作业 | 使用 |
传递的 | 目标服务拒绝令牌 | Audience必须与提供商配置的受众URL完全匹配 |
对实际机密使用 | 机密值以明文形式出现在构建日志中 | 仅对非敏感配置值使用 |
调用 | 变量仅对后续钩子/阶段生效,而非当前脚本 | 对当前脚本变量使用 |
| 通过环境变量传递大值 | 操作系统级别的环境变量大小限制导致静默截断或作业失败 | 对于大于几KB的负载,切换到基于文件的方式(工件、带文件的元数据) |
在 | 变量被意外插值,生成格式错误的YAML | 当YAML包含字面量 |
Additional Resources
额外资源
Reference Files
参考文件
- — Complete flag tables for all subcommands including upload, download, search, shasum, annotate, meta-data, pipeline upload, oidc, step, lock, env, secret, redactor, and tool
references/flag-reference.md - — Advanced multi-subcommand patterns: test failure annotation pipelines, cross-job state machines, OIDC-authenticated Docker push, parallel job coordination with locks, environment debugging
references/patterns-and-recipes.md
- — 所有子命令的完整标志表格,包括upload、download、search、shasum、annotate、meta-data、pipeline upload、oidc、step、lock、env、secret、redactor和tool
references/flag-reference.md - — 高级多子命令模式:测试失败注释流水线、跨作业状态机、OIDC认证的Docker推送、并行作业锁协调、环境调试
references/patterns-and-recipes.md