首页
看点啥
插画图片
首页 科技看点 teamcity-cli:实践指南

teamcity-cli:实践指南

2026-10-06 0

真正理解teamcity-cli,要从它处理的任务开始:从您的终端或您的 AI 中输入 TeamCity,构建、日志、代理、代理终端、队列。实际做软件开发时,经常会碰到依赖、接口和异常处理往往比主路径更影响采用,所以功能列表并不能代替验证。与其反复读介绍,不如在隔离分支完成一个可回滚的小任务,再依据安装步骤、接口契约、测试结果和错误信息做取舍。我会把它列入需要可检查开发流程而非单次演示的工程师的候选清单,而不是仅凭项目介绍直接纳入生产。

JetBrains/teamcity-cli 项目截图 1

TeamCity CLI

teamcity 是 TeamCity 的官方命令行客户端。它涵盖了日常工作 - 启动构建、跟踪日志、挖掘队列 - 以及一些零碎的工作:对构建代理进行 shell 处理、编辑作业设置、在没有其他合适的情况下进行原始 REST 调用。

完整的文档,包括安装、身份验证和命令参考,位于 jb.gg/tc/docs。

安装

macOS(自制):

brew install jetbrains/utils/teamcity

Linux:

curl -fsSL https://jb.gg/tc/install | bash

安装脚本也适用于 macOS。新安装使用 ~/.local/bin,无需 sudo;重新运行它会更新现有的非托管安装。缺失的 Bash/Zsh PATH 条目会自动添加。之后重新启动 shell,或使用打印的 PATH 命令。

Windows(Winget):

winget install JetBrains.TeamCityCLI

npm:

npm install -g @jetbrains/teamcity-cli

More 安装方法(deb、rpm、Chocolatey、Scoop、从源代码构建)

Debian/Ubuntu:

curl -fsSLO https://github.com/JetBrains/teamcity-cli/releases/latest/download/teamcity_linux_amd64.deb
sudo dpkg -i teamcity_linux_amd64.deb

RHEL/Fedora:

sudo rpm -i https://github.com/JetBrains/teamcity-cli/releases/latest/download/teamcity_linux_amd64.rpm

Arch Linux (AUR):

yay -S teamcity-bin

PowerShell:

irm https://jb.gg/tc/install.ps1 | iex

CMD:

curl -fsSL https://jb.gg/tc/install.cmd -o install.cmd && install.cmd && del install.cmd

巧克力:

choco install teamcitycli

独家新闻:

scoop bucket add jetbrains https://github.com/JetBrains/scoop-utils
scoop install teamcity

从源代码构建:

go install github.com/JetBrains/teamcity-cli/tc@latest

有关完整演练,请参阅 入门指南。

用途

为了安全起见,重定向永远不会降级 HTTPS 或将请求标头转发到另一个源。无需凭据即可继续支持跨源工件下载。

登录一次,CLI 就会记住服务器:

teamcity auth login

然后:

# my latest build on this branch
teamcity run list --user @me --branch @this --limit 1

# start a build and stay attached to it
teamcity run start MyProject_Build --branch main --watch

# pin different revisions in a job with multiple VCS roots
teamcity run start MyProject_Build --revision AppRepo=abc123 --revision AssetsRepo=@main

# logs from the latest build of a job
teamcity run log --job MyProject_Build

# what's sitting in the queue
teamcity queue list

# shell into a build agent
teamcity agent term Agent-Linux-01

一个命名说明:TeamCity 表示构建和构建配置; CLI 表示 run 和 job。 词汇表 具有完整的映射。

设置 TEAMCITY_RO=1 以阻止写入和远程 shell(agent exec 和 agent term)。使用服务器端权限作为安全边界。

每个命令都将--json或--plain用于脚本,并且--web在TeamCity UI中打开匹配的页面。当没有命令满足您的需要时,teamcity api 会使用您存储的凭据直接调用 REST API。您还可以登录多个服务器并在它们之间切换 - 请参阅 配置。

命令

神器下载仅限--output;失败或不完整的传输会保留现有文件。

集团 命令
授权 login, logout, status
运行 list, start, view, watch, log, tree, changes, tests, diff, cancel, download, artifacts, restart, pin/unpin, tag/untag, comment
工作 list, view, create, tree, pause/resume, step list/view/add/delete, param list/get/set/delete, settings list/get/set
项目 list, view, create, tree, vcs list/view/create/test/delete, ssh list/generate/upload/delete, cloud profile/image/instance, connection list/view/create github-app/create docker/authorize/delete, param, token get/put, settings export/status/validate
管道 list、view、create、validate、pull、push、schema(启用runners/features)、 delete
队列 list, approve, remove, top
代理 list, view, term, exec, jobs, authorize/deauthorize, enable/disable, move, reboot
泳池 list, view, link/unlink
服务器 plugin upload(可选配--hot-reload)
API 原始 REST API 访问
链接 通过 teamcity.toml 将此存储库绑定到 TeamCity 项目
配置 list, get, set
别名 set, list, delete
技能 list, install, remove, update
更新 检查并安装 CLI 更新(--check/--json 仅用于状态,--yes 用于非交互式安装)

使用方法请运行teamcity --help,或参见命令参考。

对于AI代理商

CLI 附带 代理技能,用于教授编码代理(Claude Code、Cursor 等)如何驱动 teamcity:

teamcity skill install           # auto-detects installed agents
teamcity skill install --project # install to current project only
teamcity skill update            # update to the version bundled with teamcity
teamcity skill remove            # uninstall

或者专门针对 Claude Code,安装 teamcity 插件,该插件 将这些技能捆绑在一起 JetBrains/teamcity-skills:

/plugin marketplace add JetBrains/teamcity-skills
/plugin install teamcity@teamcity

该插件仅提供技能 - 按上述方式安装 teamcity CLI 本身。

有关详细信息,请参阅 AI 代理集成。

了解更多

喜欢(0)

上一篇

SaaSAllTheThings:AI Agent 工具实践指南

SaaSAllTheThings:AI Agent 工具实践指南

下一篇

chatgpt-for-researchers:AI Agent 工具实践指南

chatgpt-for-researchers:AI Agent 工具实践指南
猜你喜欢