zentao-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese禅道 CLI
ZenTao CLI
通过 命令行工具查询和操作禅道数据。CLI 自动处理认证、分页,支持工作区上下文和数据过滤/排序。
zentaoQuery and operate ZenTao data via the command-line tool. The CLI automatically handles authentication and pagination, and supports workspace context, data filtering/sorting.
zentao前置准备
Prerequisites
安装
Installation
bash
npm install -g zentao-clibash
npm install -g zentao-cli或 bun install -g zentao-cli
or bun install -g zentao-cli
或 pnpm install -g zentao-cli
or pnpm install -g zentao-cli
或免安装运行:npx zentao-cli
or run without installation: npx zentao-cli
如果用户没有安装,引导用户进行全局安装使用,如果系统存在 bun 或 pnpm 则优先使用 bun 或 pnpm 进行全局安装。
If the user hasn't installed it, guide them to install it globally. If bun or pnpm is available on the system, prioritize using bun or pnpm for global installation.认证
Authentication
首次执行任意 命令会自动提示登录。也可显式登录:
zentaobash
zentao login -s https://zentao.example.com -u admin -p 123456环境变量(优先级低于命令行参数):
| 变量 | 说明 |
|---|---|
| 禅道服务地址 |
| 用户账号 |
| 密码 |
| 直接指定 Token(有此变量可省略密码) |
登录成功后凭证缓存在 ,后续无需重复登录。
~/.config/zentao/zentao.jsonThe first time you execute any command, you will be prompted to log in automatically. You can also log in explicitly:
zentaobash
zentao login -s https://zentao.example.com -u admin -p 123456Environment variables (lower priority than command-line parameters):
| Variable | Description |
|---|---|
| ZenTao service address |
| User account |
| Password |
| Specify Token directly (password can be omitted if this variable exists) |
After successful login, credentials are cached in , so you don't need to log in repeatedly later.
~/.config/zentao/zentao.json命令格式
Command Format
使用简写方式(推荐):
| 操作 | 命令 |
|---|---|
| 列表 | |
| 详情 | |
| 创建 | |
| 更新 | |
| 删除 | |
| 动作 | |
| 帮助 | |
也支持 传入 JSON 数据。
--data='JSON'Use the shorthand format (recommended):
| Operation | Command |
|---|---|
| List | |
| Details | |
| Create | |
| Update | |
| Delete | |
| Action | |
| Help | |
You can also pass JSON data using .
--data='JSON'模块与操作速查
Module & Operation Quick Reference
| 模块名 | 中文 | 支持的操作 |
|---|---|---|
| program | 项目集 | CRUD |
| product | 产品 | CRUD |
| project | 项目 | CRUD |
| execution | 执行/迭代 | CRUD |
| story | 需求 | CRUD + activate / change / close |
| epic | 业务需求 | CRUD + activate / change / close |
| requirement | 用户需求 | CRUD + activate / change / close |
| bug | Bug | CRUD + activate / close / resolve |
| task | 任务 | CRUD + activate / close / finish / start |
| testcase | 测试用例 | CRUD |
| testtask | 测试单 | CUD(按产品/项目/执行查列表) |
| productplan | 产品计划 | CUD(按产品查列表) |
| build | 版本 | CUD(按项目/执行查列表) |
| release | 发布 | CUD(按产品查列表) |
| feedback | 反馈 | CRUD + activate / close |
| ticket | 工单 | CRUD + activate / close |
| system | 应用 | CU(按产品查列表) |
| user | 用户 | CRUD |
| file | 附件 | 编辑名称 + 删除 |
CRUD = 列表 + 详情 + 创建 + 更新 + 删除;CUD = 无独立列表接口,需指定所属范围
| Module Name | Chinese | Supported Operations |
|---|---|---|
| program | Program | CRUD |
| product | Product | CRUD |
| project | Project | CRUD |
| execution | Execution/Iteration | CRUD |
| story | Story | CRUD + activate / change / close |
| epic | Epic | CRUD + activate / change / close |
| requirement | Requirement | CRUD + activate / change / close |
| bug | Bug | CRUD + activate / close / resolve |
| task | Task | CRUD + activate / close / finish / start |
| testcase | Test Case | CRUD |
| testtask | Test Task | CUD (query list by product/project/execution) |
| productplan | Product Plan | CUD (query list by product) |
| build | Build | CUD (query list by project/execution) |
| release | Release | CUD (query list by product) |
| feedback | Feedback | CRUD + activate / close |
| ticket | Ticket | CRUD + activate / close |
| system | System | CU (query list by product) |
| user | User | CRUD |
| file | Attachment | Rename + Delete |
CRUD = List + Details + Create + Update + Delete; CUD = No independent list interface, need to specify the scope
列表范围参数
List Scope Parameters
部分模块的列表需要指定所属范围:
bash
zentao story --product=1 # 产品 #1 的需求
zentao bug --product=1 # 产品 #1 的 Bug
zentao task --execution=1 # 执行 #1 的任务
zentao execution --project=5 # 项目 #5 的执行
zentao build --project=5 # 项目 #5 的版本
zentao testtask --product=1 # 产品 #1 的测试单
zentao release --product=1 # 产品 #1 的发布
zentao productplan --product=1 # 产品 #1 的计划
zentao feedback --product=1 # 产品 #1 的反馈
zentao ticket --product=1 # 产品 #1 的工单设置工作区后可省略这些参数(见下方工作区章节)。
Lists for some modules need to specify the scope:
bash
zentao story --product=1 # Stories of product #1
zentao bug --product=1 # Bugs of product #1
zentao task --execution=1 # Tasks of execution #1
zentao execution --project=5 # Executions of project #5
zentao build --project=5 # Builds of project #5
zentao testtask --product=1 # Test tasks of product #1
zentao release --product=1 # Releases of product #1
zentao productplan --product=1 # Product plans of product #1
zentao feedback --product=1 # Feedback of product #1
zentao ticket --product=1 # Tickets of product #1These parameters can be omitted after setting up the workspace (see the Workspace section below).
AI 使用策略
AI Usage Strategy
输出格式
Output Format
- 展示给用户:不加 参数,默认输出 Markdown 表格(列表)或列表(单个对象)
--format - 需要程序化处理:加 ,返回结构化 JSON
--format=json
- For display to users: Do not add the parameter, default output is Markdown table (list) or list (single object)
--format - For programmatic processing: Add to return structured JSON
--format=json
交互确认
Interactive Confirmation
AI 场景下执行删除操作时加 跳过确认提示:
--yesbash
zentao bug delete 1 --yesAdd to skip the confirmation prompt when performing delete operations in AI scenarios:
--yesbash
zentao bug delete 1 --yes不知道 ID 时
When ID is Unknown
先查列表获取 ID,再操作具体对象:
bash
zentao product --pick=id,name # 查看产品列表
zentao bug --product=1 --pick=id,title # 查看 Bug 列表
zentao bug 42 # 查看具体 BugFirst query the list to get the ID, then operate on the specific object:
bash
zentao product --pick=id,name # View product list
zentao bug --product=1 --pick=id,title # View Bug list
zentao bug 42 # View specific Bug写操作前确认
Confirmation Before Write Operations
执行创建、更新、删除等写操作前,先向用户确认操作内容。用户明确要求不确认时可跳过。
Confirm the operation content with the user before performing write operations such as create, update, delete. You can skip the confirmation if the user explicitly requests it.
数据处理
Data Processing
摘取字段
Pick Fields
bash
zentao product --pick=id,name,statusbash
zentao product --pick=id,name,status过滤
Filter
bash
zentao bug --product=1 --filter='status:active'
zentao bug --product=1 --filter='severity<=2,pri<=2' # AND
zentao bug --product=1 --filter='status:active' --filter='status:resolved' # OR支持的运算符: 等于、 不等于、 、 包含、 不包含。
:!=><>=<=~!~bash
zentao bug --product=1 --filter='status:active'
zentao bug --product=1 --filter='severity<=2,pri<=2' # AND
zentao bug --product=1 --filter='status:active' --filter='status:resolved' # ORSupported operators: equals, not equals, , contains, does not contain.
:!=><>=<=~!~模糊搜索
Fuzzy Search
bash
zentao bug --product=1 --search=登录 --search-fields=title,stepsbash
zentao bug --product=1 --search=login --search-fields=title,steps排序
Sort
bash
zentao bug --product=1 --sort=pri_asc,severity_ascbash
zentao bug --product=1 --sort=pri_asc,severity_asc分页
Pagination
bash
zentao bug --product=1 --page=1 --recPerPage=50
zentao bug --product=1 --all # 获取全部
zentao bug --product=1 --limit=10 # 只取前 10 条bash
zentao bug --product=1 --page=1 --recPerPage=50
zentao bug --product=1 --all # Get all
zentao bug --product=1 --limit=10 # Get only the first 10 items常用操作示例
Common Operation Examples
查看进行中的项目和执行
View Ongoing Projects and Executions
bash
zentao project --filter='status:doing' --pick=id,name,status
zentao execution --project=5 --pick=id,name,statusbash
zentao project --filter='status:doing' --pick=id,name,status
zentao execution --project=5 --pick=id,name,status创建需求
Create a Story
bash
zentao story create --product=1 --title="需求标题" --assignedTo=admin --pri=3bash
zentao story create --product=1 --title="Story Title" --assignedTo=admin --pri=3创建并解决 Bug
Create and Resolve a Bug
bash
zentao bug create --product=1 --title="Bug标题" --severity=2 --pri=2 --type=codeerror --openedBuild=trunk
zentao bug resolve 42bash
zentao bug create --product=1 --title="Bug Title" --severity=2 --pri=2 --type=codeerror --openedBuild=trunk
zentao bug resolve 42创建、启动并完成任务
Create, Start and Finish a Task
bash
zentao task create --execution=1 --name="任务名" --type=devel --assignedTo=admin --estimate=4
zentao task start 100
zentao task finish 100 --consumed=4bash
zentao task create --execution=1 --name="Task Name" --type=devel --assignedTo=admin --estimate=4
zentao task start 100
zentao task finish 100 --consumed=4查看帮助
View Help
bash
zentao bug help # 查看 Bug 模块的参数和操作
zentao help # 查看所有命令bash
zentao bug help # View parameters and operations for the Bug module
zentao help # View all commands意图识别
Intent Recognition
| 用户意图 | CLI 命令 |
|---|---|
| 所有产品/项目/项目集 | |
| 进行中的项目 | |
| 某产品的 Bug | |
| 某执行的任务 | |
| 创建/新增 Bug | |
| 解决 Bug | |
| 关闭 Bug | |
| 激活 Bug | |
| 创建需求 | |
| 变更/关闭/激活需求 | |
| 业务需求 | |
| 用户需求 | |
| 创建/启动/完成/关闭任务 | |
| 测试用例 | |
| 测试单 | |
| 产品计划 | |
| 版本/Build | |
| 发布 | |
| 反馈 | |
| 工单 | |
| 用户列表 | |
| 当前用户信息 | |
| User Intent | CLI Command |
|---|---|
| All products/projects/programs | |
| Ongoing projects | |
| Bugs of a product | |
| Tasks of an execution | |
| Create/add a Bug | |
| Resolve a Bug | |
| Close a Bug | |
| Activate a Bug | |
| Create a story | |
| Change/close/activate a story | |
| Epic | |
| Requirement | |
| Create/start/finish/close a task | |
| Test case | |
| Test task | |
| Product plan | |
| Build | |
| Release | |
| Feedback | |
| Ticket | |
| User list | |
| Current user info | |
错误处理
Error Handling
| 错误码 | 含义 | 处理方式 |
|---|---|---|
| E1001 | 未登录/凭证缺失 | 执行 |
| E1004 | Token 失效 | 执行 |
| E2001 | 模块不存在 | 执行 |
| E2002 | 对象不存在 | 检查 ID 是否正确 |
| E2003 | 缺少必要参数 | 执行 |
| E2006 | 无权限 | 提示用户检查权限 |
| E5001 | 请求超时 | 检查网络或禅道服务状态 |
| Error Code | Meaning | Solution |
|---|---|---|
| E1001 | Not logged in/credentials missing | Execute |
| E1004 | Token expired | Execute |
| E2001 | Module does not exist | Execute |
| E2002 | Object does not exist | Check if the ID is correct |
| E2003 | Missing required parameters | Execute |
| E2006 | No permission | Prompt the user to check permissions |
| E5001 | Request timeout | Check network or ZenTao service status |
注意事项
Notes
- 不确定模块参数时,先执行 查看帮助
zentao <module> help - 常用值:
browseType(全部)、all(进行中)、doing(已关闭)closed - 静默模式:只输出错误信息
--silent - 多账号切换:查看和切换账号
zentao profile
- When unsure about module parameters, execute to view help first
zentao <module> help - Common values for :
browseType(all),all(ongoing),doing(closed)closed - Silent mode: only outputs error messages
--silent - Multi-account switching: to view and switch accounts
zentao profile