buildkite/agent
GitHub: buildkite/agent
Buildkite Agent 是一个用 Go 编写的开源跨平台构建运行器,用于在用户自有基础设施上安全地执行来自 Buildkite 平台的自动化构建作业。
Stars: 1025 | Forks: 367
# Buildkite Agent

[](https://pkg.go.dev/github.com/buildkite/agent/v3)
buildkite-agent 是一个小巧、可靠且跨平台的构建运行器,可以
让您轻松地在自己的基础设施上运行自动化构建。它的主要
职责是轮询 [buildkite.com](https://buildkite.com/) 获取任务,
运行构建作业,回报作业的状态码和输出日志,
以及上传作业的 artifacts。
完整文档可在
[buildkite.com/docs/agent](https://buildkite.com/docs/agent) 获取。
```
$ buildkite-agent --help
Usage:
buildkite-agent [options...]
Available commands are:
acknowledgements Prints the licenses and notices of open source software incorporated into this software.
start Starts a Buildkite agent
annotate Annotate the build page within the Buildkite UI with text from within a Buildkite job
annotation Make changes to an annotation on the currently running build
artifact Upload/download artifacts from Buildkite jobs
env Process environment subcommands
lock Process lock subcommands
meta-data Get/set data from Buildkite jobs
oidc Interact with Buildkite OpenID Connect (OIDC)
pipeline Make changes to the pipeline of the currently running build
step Get or update an attribute of a build step
bootstrap Run a Buildkite job locally
help Shows a list of commands or help for one command
Use "buildkite-agent --help" for more information about a command.
```
## 依赖
该 agent 具有相当高的可移植性,无需额外组件即可在大多数受支持的
平台上开箱即用。在 Linux 主机上,它需要 `dbus`。
## 安装
Buildkite 上的 [Agents 页面](https://buildkite.com/organizations/-/agents) 提供了
个性化的说明,您也可以参考
[Buildkite 文档](https://buildkite.com/docs/agent/self-hosted/install)。这两者
都涵盖了如何通过 Ubuntu(通过 apt)、Debian(通过 apt)、macOS(通过
homebrew)、Windows 和 Linux 安装 agent。
### Docker
我们还为以下
操作系统支持并发布了
[Docker 镜像](https://hub.docker.com/r/buildkite/agent)。Docker 镜像使用 agent 的 SemVer 组件
加上操作系统进行标签标记。
例如,agent 版本 3.45.6 会发布为:
- 3-ubuntu-20.04,跟踪安装在 Ubuntu 20.04 上的版本 3 的次要和错误修复更新
- 3.45-ubuntu-20.04,跟踪安装在 Ubuntu 20.04 上的版本 3.45 的错误修复更新
- 3.45.6-ubuntu-20.04,跟踪安装在 Ubuntu 20.04 上的确切版本
#### 支持的操作系统
- Alpine 3.18
- Ubuntu 20.04 LTS (x86_64),支持至 20.04 标准支持结束
- Ubuntu 22.04 LTS (x86_64),支持至 22.04 标准支持结束
- Ubuntu 24.04 LTS (x86_64),支持至 24.04 标准支持结束
## 启动
要启动一个 agent,您只需要您的 agent token(您可以在 Buildkite 的
Agents 页面找到)以及一个构建路径。例如:
```
buildkite-agent start --token= --build-path=/tmp/buildkite-builds
```
### 遥测
默认情况下,agent 会将有关该 agent 上正在使用的功能的一些信息发送回 Buildkite 母舰。不会向 Buildkite 发送任何敏感或可识别身份的信息,但如果您愿意,您可以通过
在您的 `buildkite-agent start` 调用中添加 `--no-feature-reporting` 标志来禁用此功能报告。
我们跟踪的功能可以在
[AgentStartConfig.Features](https://github.com/search?q=repo%3Abuildkite%2Fagent+language%3Ago+symbol%3AAgentStartConfig.Features+&type=code) 中找到。
## 开发
这些说明假设您运行的是较新版本的 macOS,但可以轻松
适配到 Linux 和 Windows。
```
# 确保你已经安装了 Go。
brew install go
# 将代码下载到某个位置 - 不需要 GOPATH。
git clone https://github.com/buildkite/agent.git
cd agent
# 创建一个临时的 builds 目录。
mkdir /tmp/buildkite-builds
# 构建 agent 二进制文件并启动 agent。
go build -o /usr/local/bin/buildkite-agent .
buildkite-agent start --debug --build-path=/tmp/buildkite-builds --token "abc"
# 或者,直接运行 agent 并跳过 build 步骤。
go run *.go start --debug --build-path=/tmp/buildkite-builds --token "abc"
```
### Go 版本和依赖管理
最新的 agent 版本通常使用最高版本的稳定版
Go 编译。以前的 Go 版本可能可以工作,但不作保证。我们正在
使用较新的语言特性(如泛型),因此在 Go < 1.18 上编译将
失败。
我们正在使用 [Go Modules](https://github.com/golang/go/wiki/Modules) 来管理
我们的 Go 依赖。除非
必要,否则依赖项不会
[vendored](https://go.dev/ref/mod#go-mod-vendor) 到仓库中。
此 repo 发布的 Go 模块(即您可以通过在代码中添加 `import "github.com/buildkite/agent/v3"` 来使用的模块)
**不被视为使用语义化版本控制进行版本控制**。次要版本中可能会引入破坏性更改。将
agent 作为您的 Go 应用的 runtime 依赖项使用需您自担风险。
## 平台支持
我们仅为当前的主要版本提供安全和错误修复支持。
我们的架构和操作系统支持主要受限于
[Go 本身支持的内容](https://github.com/golang/go/wiki/MinimumRequirements)。
### 架构支持
我们支持以下机器架构(受 Rust
语言平台支持指南启发)。
#### 第一梯队,保证可运行
- linux x86_64
- linux arm64
- windows x86_64
#### 第二梯队,保证可构建
- linux x86
- windows x86
- darwin x86_64
- darwin arm64
#### 第三梯队,社区支持
我们发布了适用于各种其他平台的二进制文件,并且应该可以在
Go 支持的任何地方构建 agent,但不提供这些
第三梯队平台的官方支持。
### 操作系统支持
我们目前支持在以下
操作系统上运行 Buildkite Agent。未来的_次要_版本可能会停止对已停止支持的生命周期结束操作系统(通常是因为它们不再受最新稳定版 Go
发布版支持)的支持。
agent 二进制文件具有相当高的可移植性,应该可以在大多数类 UNIX
系统以及 Windows 上开箱即用。
- Ubuntu 20.04 及更高版本
- Debian 8 及更高版本
- Red Hat RHEL 7 及更高版本
- CentOS
- CentOS 7
- CentOS 8
- Amazon Linux 2
- macOS [^1]
- 12 (Monterey)
- 13 (Ventura)
- 14 (Sonoma)
- 15 (Sequoia)
- 26 (Tahoe)
- Windows [^2]
- 10
- 11
- Server 2016
- Server 2019
- Server 2022
[^1]: 有关 macOS / Go 支持,请参见 https://github.com/golang/go/issues/23011,有关
上述版本之前的 macOS 版本最后支持的
Buildkite Agent 版本,请参见[受支持的 macOS 版本](./docs/macos.md)。
[^2]: 有关 Go / Windows 版本
兼容性,请参见 [Go 的 Windows 支持页面](https://go.dev/wiki/Windows),有关上述版本之前的 Windows 版本最后支持的
Buildkite Agent 版本,请参见[受支持的 Windows 版本](./docs/windows.md)。
## 贡献者
非常感谢
[我们优秀的贡献者](https://github.com/buildkite/agent/graphs/contributors)!
你们太棒了,我们非常感谢你们的输入 ❤️
## 版权
版权所有 (c) 2014-2023 Buildkite Pty Ltd.
详情请参见 [LICENSE](./LICENSE.txt)。
标签:EVTX分析, 日志审计, 请求拦截