别名
别名允许为常用 teamCity 命令创建自定义快捷键。 它们存储在 配置文件 中,运行时会自动展开。
创建别名
使用 teamcity alias set 创建别名:
teamcity alias set rl 'run list'
现在 teamcity rl 会扩展为 teamcity run list。

位置实参
对于位置实参,请使用 $1、 $2 等:
teamcity alias set rw 'run view $1 --web'
现在 teamcity rw 12345 会扩展为 teamcity run view 12345 --web。
未匹配到占位符的额外实参会追加到展开命令的末尾。
Shell 别名
对于需要管道、重定向或其他 shell 功能的别名,请在展开时加上 ! 前缀或使用 --shell 标志:
teamcity alias set watchnotify '!teamcity run watch $1 && notify-send "Build $1 done"'
teamcity alias set faillog '!teamcity run list --status=failure --json | jq ".[].id"'
Shell 别名通过 sh 进行评估,而不是直接展开。
列出别名
查看全部已配置的别名:
teamcity alias list
teamcity alias list --json
删除别名
移除别名:
teamcity alias delete rl
有用的别名示例
以下是常用的别名集合:
快速快捷键
teamcity alias set rl 'run list'
teamcity alias set rv 'run view $1'
teamcity alias set rw 'run view $1 --web'
teamcity alias set jl 'job list'
teamcity alias set ql 'queue list'
筛选视图
teamcity alias set mine 'run list --user=@me'
teamcity alias set fails 'run list --status=failure --since=24h'
teamcity alias set running 'run list --status=running'
teamcity alias set morning 'run list --status=failure --since=12h'
构建工作流程
teamcity alias set go 'run start $1 --watch'
teamcity alias set try 'run start $1 --local-changes --watch'
teamcity alias set hotfix 'run start $1 --top --clean --watch'
teamcity alias set retry 'run restart $1 --watch'
队列管理
teamcity alias set rush 'queue top $1'
teamcity alias set ok 'queue approve $1'
代理操作
teamcity alias set maint 'agent disable $1'
teamcity alias set unmaint 'agent enable $1'
API 快捷键
teamcity alias set whoami "api '/app/rest/users/current'"
带外部工具的 Shell 别名
teamcity alias set watchnotify '!teamcity run watch $1 && notify-send "Build $1 done"'
teamcity alias set faillog '!teamcity run list --status=failure --json | jq ".[].id"'
存储
别名存储在 aliases 的 ~/.config/tc/config.yml 部分:
aliases:
rl: 'run list'
rw: 'run view $1 --web'
mine: 'run list --user=@me'
fails: 'run list --status=failure --since=24h'
还可以直接编辑此文件。
2026年 8月 6日