dx-devops-work-item-manage
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDevOps Center Work Item Management
DevOps Center工作项管理
Manages the complete work item lifecycle in DevOps Center — from creation through status transitions to promotion readiness. Provides headless CLI-driven operations for autonomous release workflows.
管理DevOps Center中工作项的完整生命周期——从创建、状态转换到准备晋升。为自主发布工作流提供无头CLI驱动的操作。
Scope
适用范围
- In scope: List work items, create new work items, commit changes to work item branches, update work item fields (subject, description, status), transition work item status (New → In Progress → Ready to Promote), create pull requests for work item branches
- Out of scope: Promotion/deployment, conflict detection, pipeline or project management (separate skills)
- 包含范围:列出工作项、创建新工作项、向工作项分支提交更改、更新工作项字段(主题、描述、状态)、转换工作项状态(新建 → 进行中 → 准备晋升)、为工作项分支创建拉取请求
- 排除范围:晋升/部署、冲突检测、流水线或项目管理(由单独技能处理)
Required Inputs
必要输入
Gather or infer before proceeding:
- Operation type: list, create, update, commit, or create-review
- For list: project ID (required) — obtain via if not provided
sf devops project list --json - For create: project ID (required), subject (required), description (optional)
- For commit: work item name or ID (required) to retrieve branch name, files to commit, commit message
- For update: work item name (e.g., WI-000001) or work item ID (required), fields to update (subject, description, status)
- For create-review: work item name (e.g., WI-000001) or work item ID (required)
Defaults unless specified:
- Output format: for headless consumption
--json - Work item identifier: prefer (WI-000001) over
--work-item-namewhen both are available (names are human-readable)--work-item-id
If the user provides a clear request ("list work items for Project Alpha", "create work item to fix login bug", "move WI-12345 to In Progress", "create PR for WI-12345"), proceed immediately without unnecessary questions.
执行前需收集或推断:
- 操作类型:list(列出)、create(创建)、update(更新)、commit(提交)或create-review(创建审查)
- 列出操作:项目ID(必填)——若未提供,可通过获取
sf devops project list --json - 创建操作:项目ID(必填)、主题(必填)、描述(可选)
- 提交操作:工作项名称或ID(必填)用于获取分支名称、需提交的文件、提交信息
- 更新操作:工作项名称(如WI-000001)或工作项ID(必填)、需更新的字段(主题、描述、状态)
- 创建审查操作:工作项名称(如WI-000001)或工作项ID(必填)
未指定时的默认值:
- 输出格式:,用于无头环境消费
--json - 工作项标识符:当名称和ID均可用时,优先使用(如WI-000001)而非
--work-item-name(名称更易读)--work-item-id
若用户提供明确请求(如“列出Alpha项目的工作项”、“创建修复登录bug的工作项”、“将WI-12345改为进行中状态”、“为WI-12345创建PR”),无需额外提问直接执行。
Workflow
工作流程
All operations use CLI commands with output for structured consumption.
sf devops work-item--json所有操作均使用 CLI命令,并添加参数以获取结构化输出。
sf devops work-item--jsonPhase 1 — Identify Operation
阶段1 — 确定操作类型
- Determine the operation type from user intent:
- Keywords like "list", "show", "find" → list operation
- Keywords like "create", "new", "add" → create operation
- Keywords like "commit", "push", "save changes", "git commit" → commit operation
- Keywords like "update", "change", "modify", "edit", "move", "transition", "advance", "mark as" → update operation
- Keywords like "create PR", "pull request", "code review", "review", "open PR" → create-review operation
- 根据用户意图确定操作类型:
- 关键词如“list”、“show”、“find” → 列出操作
- 关键词如“create”、“new”、“add” → 创建操作
- 关键词如“commit”、“push”、“save changes”、“git commit” → 提交操作
- 关键词如“update”、“change”、“modify”、“edit”、“move”、“transition”、“advance”、“mark as” → 更新操作
- 关键词如“create PR”、“pull request”、“code review”、“review”、“open PR” → 创建审查操作
Phase 2 — Execute Operation
阶段2 — 执行操作
-
Verify org authentication before any operation:bash
sf org display --json- If no default org is set or authentication has expired, instruct the user to run:
bash
sf org login web --set-default --alias <alias> - Verify the authenticated org has DevOps Center enabled by attempting to list projects
- If the user wants to target a specific org, use on all subsequent commands
--target-org <alias>
- If no default org is set or authentication has expired, instruct the user to run:
-
List work items — when the user wants to see existing work items:bash
sf devops work-item list --project-id <project-id> --json- is required — if the user provides a project name instead of ID, first run
--project-idto resolve the name to an IDsf devops project list --json - Verify the command returns status 0 (success)
- Parse the JSON output: the work items are in the array
.result[] - Each work item has: (e.g., WI-000001),
name,subject,branch,environment,statusdescription - Present in a readable format showing work item name, subject, status, branch, and environment
- If is an empty array, confirm "No work items found in project <project-name>."
.result[] - If the user requested filtering by status (e.g., "show work items in Ready to Promote status"), run:
Then present the matching work itemsbash
sf devops work-item list --project-id <id> --json | jq '.result[] | select(.status == "<requested-status>")'
-
Create a work item — when the user wants to create a new work item:bash
sf devops work-item create \ --project-id <project-id> \ --subject "<subject>" \ --description "<description>" \ --json- is required (obtain from user or via
--project-id)sf devops project list --json - is required (user-facing title)
--subject - is optional (defaults to blank if omitted)
--description - Capture the returned work item name (e.g., WI-000001), branch name, and environment from JSON output for future operations
- Idempotent: if the user attempts to create a duplicate (same subject + project), check via list first and return the existing work item
-
Execute commit operation — when operation type is commit:
- DevOps Center creates a dedicated feature branch for each work item (returned in the create operation)
- The user must commit and push changes to this branch before transitioning status or creating a PR
- Standard git workflow:
bash
git checkout <branch-name> git add <files> git commit -m "<commit-message>" git push origin <branch-name> - The branch name is available from the work item's field (retrieve via list or create operation)
branch - Changes must be committed before the work item can be marked "Ready to Promote" or before creating a PR
-
Update work item — when the user wants to change subject, description, or status:bash
sf devops work-item update \ --work-item-name <WI-name> \ --subject "<new-subject>" \ --description "<new-description>" \ --status "<In Progress|Ready to Promote>" \ --json- Work item identifier is required: use (preferred) or
--work-item-name <WI-000001>--work-item-id <id> - If the user provides a work item by subject instead of name, resolve it to a name first:
Then pass the returned name (e.g., WI-000001) to the update commandbash
sf devops work-item list --project-id <id> --json | jq -r '.result[] | select(.subject == "<user-provided-subject>") | .name' - At least one of ,
--subject, or--descriptionmust be provided--status - Valid status values: "In Progress" or "Ready to Promote" (exact strings with spaces)
- Only include flags for fields being updated (omit unchanged fields)
- Verify the command returns status 0 (success)
- Parse the JSON response: ,
.result.name,.result.subjectcontain the updated values.result.status - For status transitions specifically: after the command completes, explicitly confirm the new status by checking in the response. If the status field is absent from the update response, re-query the work item via list to verify the status persisted
.result.status
- Work item identifier is required: use
-
Create pull request — when the user wants to create a PR for code review:bash
sf devops review create \ --work-item-name <WI-name> \ --json- Work item identifier is required: use (preferred) or
--work-item-name <WI-000001>--work-item-id <id> - If the user provides a work item by subject instead of name, resolve it to a name first:
Then pass the returned name (e.g., WI-000001) to the review create commandbash
sf devops work-item list --project-id <id> --json | jq -r '.result[] | select(.subject == "<user-provided-subject>") | .name' - Creates PR via DevOps Center API using VCS credentials stored in the org
- No local VCS authentication required — DevOps Center handles GitHub/Bitbucket auth
- Works with GitHub and Bitbucket
- Verify the command returns status 0 (success)
- Parse the JSON response: contains the PR URL,
.result.pullRequestUrlcontains the PR status (typically "open" for newly created PRs),.result.statuscontains the PR number.result.number - If the command fails with a VCS credentials error, instruct the user to configure VCS credentials in the DevOps Center org (Setup → DevOps Center → VCS Credentials)
- If the command fails with "PR already exists" error, report that a PR already exists for this work item (idempotent operation)
- Work item identifier is required: use
-
执行任何操作前验证组织身份验证:bash
sf org display --json- 若未设置默认组织或身份验证已过期,指导用户运行:
bash
sf org login web --set-default --alias <alias> - 通过尝试列出项目,验证已认证组织是否启用了DevOps Center
- 若用户想要指定目标组织,在后续所有命令中添加参数
--target-org <alias>
- 若未设置默认组织或身份验证已过期,指导用户运行:
-
列出工作项 — 用户需要查看现有工作项时:bash
sf devops work-item list --project-id <project-id> --json- 为必填项 — 若用户提供的是项目名称而非ID,先运行
--project-id将名称解析为IDsf devops project list --json - 验证命令返回状态码为0(成功)
- 解析JSON输出:工作项位于数组中
.result[] - 每个工作项包含:(如WI-000001)、
name、subject、branch、environment、statusdescription - 以易读格式展示工作项名称、主题、状态、分支和环境
- 若为空数组,确认“<项目名称>项目中未找到工作项。”
.result[] - 若用户要求按状态筛选(如“显示处于准备晋升状态的工作项”),运行:
然后展示匹配的工作项bash
sf devops work-item list --project-id <id> --json | jq '.result[] | select(.status == "<requested-status>")'
-
创建工作项 — 用户需要创建新工作项时:bash
sf devops work-item create \ --project-id <project-id> \ --subject "<subject>" \ --description "<description>" \ --json- 为必填项(从用户处获取或通过
--project-id获取)sf devops project list --json - 为必填项(面向用户的标题)
--subject - 为可选项(若省略则默认为空)
--description - 从JSON输出中捕获返回的工作项名称(如WI-000001)、分支名称和环境,用于后续操作
- 幂等性:若用户尝试创建重复工作项(相同主题+项目),先通过列出操作检查并返回现有工作项
-
执行提交操作 — 操作类型为提交时:
- DevOps Center为每个工作项创建专用功能分支(在创建操作中返回)
- 用户必须先将更改提交并推送到此分支,才能转换状态或创建PR
- 标准Git工作流:
bash
git checkout <branch-name> git add <files> git commit -m "<commit-message>" git push origin <branch-name> - 分支名称可从工作项的字段获取(通过列出或创建操作检索)
branch - 必须先提交更改,才能将工作项标记为“准备晋升”或创建PR
-
更新工作项 — 用户需要更改主题、描述或状态时:bash
sf devops work-item update \ --work-item-name <WI-name> \ --subject "<new-subject>" \ --description "<new-description>" \ --status "<In Progress|Ready to Promote>" \ --json- 工作项标识符为必填项:使用(优先)或
--work-item-name <WI-000001>--work-item-id <id> - 若用户提供的是工作项主题而非名称,先将其解析为名称:
然后将返回的名称(如WI-000001)传入更新命令bash
sf devops work-item list --project-id <id> --json | jq -r '.result[] | select(.subject == "<user-provided-subject>") | .name' - 必须至少提供、
--subject或--description中的一个--status - 有效状态值:"In Progress"或"Ready to Promote"(带空格的精确字符串)
- 仅包含需更新字段的参数(省略未更改的字段)
- 验证命令返回状态码为0(成功)
- 解析JSON响应:、
.result.name、.result.subject包含更新后的值.result.status - 状态转换专用:命令完成后,通过检查响应中的明确确认新状态。若更新响应中缺少状态字段,重新通过列出操作查询工作项以验证状态是否已持久化
.result.status
- 工作项标识符为必填项:使用
-
创建拉取请求 — 用户需要创建用于代码审查的PR时:bash
sf devops review create \ --work-item-name <WI-name> \ --json- 工作项标识符为必填项:使用(优先)或
--work-item-name <WI-000001>--work-item-id <id> - 若用户提供的是工作项主题而非名称,先将其解析为名称:
然后将返回的名称(如WI-000001)传入审查创建命令bash
sf devops work-item list --project-id <id> --json | jq -r '.result[] | select(.subject == "<user-provided-subject>") | .name' - 通过DevOps Center API使用组织中存储的VCS凭据创建PR
- 无需本地VCS身份验证 — DevOps Center处理GitHub/Bitbucket身份验证
- 支持GitHub和Bitbucket
- 验证命令返回状态码为0(成功)
- 解析JSON响应:包含PR链接,
.result.pullRequestUrl包含PR状态(新建PR通常为"open"),.result.status包含PR编号.result.number - 若命令因VCS凭据错误失败,指导用户在DevOps Center组织中配置VCS凭据(设置 → DevOps Center → VCS凭据)
- 若命令因“PR已存在”错误失败,告知用户此工作项的PR已存在(幂等操作)
- 工作项标识符为必填项:使用
Phase 3 — Verify and Report
阶段3 — 验证并报告结果
-
Verify operation success:
- For list: confirm the CLI returned status 0, parse the JSON array, and verify it contains work items (or is empty if no matches). If the user specified a project by name, confirm the resolved project ID matches.
.result[] - For create: verify the CLI returned status 0 and the JSON output contains (work item ID like WI-000001),
.result.name(branch name), and.result.branchfields..result.environment - For commit: verify each git command returned exit code 0. If succeeds, the commit is saved to the work item branch.
git push - For update (general fields): verify the CLI returned status 0 and compare the returned JSON fields against the user's requested changes. If updating subject, confirm matches the new value.
.result.subject - For update (status transition): verify the CLI returned status 0, then explicitly confirm the status transition by checking in the JSON response matches the target status (e.g., "Ready to Promote"). If the response doesn't include the status field, re-run
.result.statusfiltered to this work item and verify the status persisted.sf devops work-item list - For create-review: verify the CLI returned status 0 and the JSON output contains (the PR URL) and
.result.pullRequestUrl(should be "open" or equivalent). If VCS credentials are missing, the CLI returns an error — surface this to the user..result.status
- For list: confirm the CLI returned status 0, parse the JSON
-
Report results:
- List: present work items in a readable format showing work item name, subject, status, branch, and environment. If filtering by status was requested, show only matching work items.
- Create: return the work item name (e.g., WI-000001), branch name, environment, and confirm "Work item created successfully."
- Commit: confirm which files were staged, the commit SHA (from git output), and "Changes committed and pushed to branch <branch-name>."
- Update (general): confirm which fields changed with before/after values (e.g., "Subject updated from 'X' to 'Y'").
- Status transition: explicitly state the transition with old → new status (e.g., "Status updated: In Progress → Ready to Promote").
- Create-review: return the PR URL and confirm "Pull request created successfully. Status: open. URL: <url>"
-
验证操作成功:
- 列出操作:确认CLI返回状态码为0,解析JSON 数组,验证其包含工作项(或无匹配时为空)。若用户按名称指定项目,确认解析后的项目ID匹配。
.result[] - 创建操作:验证CLI返回状态码为0,且JSON输出包含(如WI-000001的工作项ID)、
.result.name(分支名称)和.result.branch字段。.result.environment - 提交操作:验证每个git命令返回退出码为0。若成功,则提交已保存到工作项分支。
git push - 更新操作(常规字段):验证CLI返回状态码为0,并将返回的JSON字段与用户请求的更改进行对比。若更新主题,确认匹配新值。
.result.subject - 更新操作(状态转换):验证CLI返回状态码为0,然后明确确认状态转换,检查JSON响应中的是否匹配目标状态(如"Ready to Promote")。若响应不包含状态字段,重新运行
.result.status并筛选此工作项,验证状态是否已持久化。sf devops work-item list - 创建审查操作:验证CLI返回状态码为0,且JSON输出包含(PR链接)和
.result.pullRequestUrl(应为"open"或等效状态)。若缺少VCS凭据,CLI会返回错误——将此信息告知用户。.result.status
- 列出操作:确认CLI返回状态码为0,解析JSON
-
报告结果:
- 列出操作:以易读格式展示工作项名称、主题、状态、分支和环境。若请求按状态筛选,仅展示匹配的工作项。
- 创建操作:返回工作项名称(如WI-000001)、分支名称、环境,并确认“工作项创建成功。”
- 提交操作:确认已暂存的文件、提交SHA(来自git输出),并提示“更改已提交并推送到分支<branch-name>。”
- 更新操作(常规):确认哪些字段已更改,并显示前后值(如“主题已从'X'更新为'Y'”)。
- 状态转换:明确说明状态转换的前后值(如“状态已更新:进行中 → 准备晋升”)。
- 创建审查操作:返回PR链接,并确认“拉取请求创建成功。状态:open。链接:<url>”
Rules / Constraints
规则/约束
| Constraint | Rationale |
|---|---|
All sf devops commands must use | Structured output is required for headless consumption; human-readable output is unreliable for parsing |
| Work item identifier required for commit, update, and create-review | Use |
| Project ID required for list and create | All work items belong to a project; use |
| At least one update field required | Update command fails if no |
| Status values must be exact strings | "In Progress" and "Ready to Promote" (with spaces, proper capitalization); other values fail |
| Idempotent create operations | Check for existing work item with same subject + project before creating duplicates |
| Changes must be committed before status transition to Ready to Promote | DevOps Center validates that the work item branch has commits before allowing promotion readiness |
| PR creation requires VCS credentials in org | DevOps Center API uses stored VCS credentials; no local git auth needed |
| Never use interactive prompts | Skills run in headless environments; all inputs must be via CLI flags |
| 约束 | 理由 |
|---|---|
所有sf devops命令必须使用 | 无头环境消费需要结构化输出;人类可读输出解析不可靠 |
| 提交、更新和创建审查操作需要工作项标识符 | 使用 |
| 列出和创建操作需要项目ID | 所有工作项都属于某个项目;若未提供,使用 |
| 更新操作至少需要一个更新字段 | 若未提供 |
| 状态值必须是精确字符串 | 仅支持"In Progress"和"Ready to Promote"(带空格、正确大小写);其他值会失败 |
| 创建操作具有幂等性 | 创建重复项前,检查是否存在相同主题+项目的工作项 |
| 转换为准备晋升状态前必须提交更改 | DevOps Center会验证工作项分支是否有提交,然后才允许设置晋升就绪状态 |
| 创建PR需要组织中的VCS凭据 | DevOps Center API使用存储的VCS凭据;无需本地git身份验证 |
| 禁止使用交互式提示 | 技能在无头环境中运行;所有输入必须通过CLI参数提供 |
Gotchas
常见问题
| Issue | Resolution |
|---|---|
| No default org set | Run |
| User provides work item by subject, not name | Resolve via: |
| User provides project by name, not ID | First run |
| Status update response missing status field | The CLI doesn't always return the status field in the update response; re-run |
| Work item not found | User provided invalid work item name/ID; run list command to show available work items |
| Invalid status value | Only "In Progress" and "Ready to Promote" are valid (exact strings with spaces); check spelling and capitalization |
| Project not found | User provided invalid project ID; run |
| Duplicate work item subject | Idempotent create check should catch this; return existing work item name instead of creating duplicate |
| Git push fails - no commits or branch not found | Verify files are staged with |
| PR creation fails - VCS credentials | VCS credentials not configured in DevOps Center UI; instruct user to configure in Setup → DevOps Center → VCS Credentials |
| 问题 | 解决方法 |
|---|---|
| 未设置默认组织 | 先运行 |
| 用户提供工作项主题而非名称 | 通过以下命令解析: |
| 用户提供项目名称而非ID | 先运行 |
| 状态更新响应缺少状态字段 | CLI在更新响应中并不总是返回状态字段;重新运行 |
| 未找到工作项 | 用户提供了无效的工作项名称/ID;运行列出命令展示可用工作项 |
| 无效状态值 | 仅"In Progress"和"Ready to Promote"为有效状态(带空格的精确字符串);检查拼写和大小写 |
| 未找到项目 | 用户提供了无效的项目ID;运行 |
| 工作项主题重复 | 幂等性创建检查应捕获此情况;返回现有工作项名称而非创建重复项 |
| Git推送失败 - 无提交或未找到分支 | 通过 |
| PR创建失败 - VCS凭据问题 | DevOps Center UI中未配置VCS凭据;指导用户在设置 → DevOps Center → VCS凭据中配置 |
Output Expectations
输出预期
Deliverables vary by operation:
- List: JSON array of work items with work item name (WI-######), subject, branch, environment, repository details
- Create: Work item name (e.g., WI-000001), ID, branch name, and environment of the newly created work item
- Commit: Confirmation of git commit and push success, with commit SHA
- Update: Confirmation of updated fields (old value → new value for subject/description, or status change)
- Create-review: Pull request URL, PR number, and status
Outputs are derived from CLI, CLI, and standard git commands.
sf devops work-itemsf devops review create交付内容因操作而异:
- 列出操作:工作项的JSON数组,包含工作项名称(WI-######)、主题、分支、环境、仓库详情
- 创建操作:新建工作项的名称(如WI-000001)、ID、分支名称和环境
- 提交操作:Git提交和推送成功的确认信息,以及提交SHA
- 更新操作:已更新字段的确认信息(主题/描述的旧值→新值,或状态变更)
- 创建审查操作:拉取请求链接、PR编号和状态
输出内容来自 CLI、 CLI和标准Git命令。
sf devops work-itemsf devops review createVerification Checklist
验证清单
Before reporting results to the user:
向用户报告结果前:
Universal Checks
通用检查
- Was org authentication verified with ?
sf org display --json - Was the CLI command executed with flag?
--json - Did the CLI return a successful exit code (0)?
- Is the JSON output parseable and non-empty?
- If multi-org scenario, was specified on all commands?
--target-org
- 是否已通过验证组织身份验证?
sf org display --json - CLI命令是否使用了参数?
--json - CLI是否返回了成功退出码(0)?
- JSON输出是否可解析且非空?
- 若为多组织场景,所有命令是否都指定了?
--target-org
List Operation Checks
列出操作检查
- Was provided?
--project-id - Are work items displayed with work item name, subject, branch, environment?
- If the list is empty, was this communicated to the user?
- 是否已提供?
--project-id - 是否展示了工作项名称、主题、分支、环境?
- 若列表为空,是否已告知用户?
Create Operation Checks
创建操作检查
- Was a work item name (WI-######) and ID returned in the JSON output?
- Was the branch name returned in the JSON output?
- Was provided and included in the command?
--subject - Was provided (or obtained via project list)?
--project-id
- JSON输出是否返回了工作项名称(WI-######)和ID?
- JSON输出是否返回了分支名称?
- 是否已提供并包含在命令中?
--subject - 是否已提供(或通过项目列表获取)?
--project-id
Commit Operation Checks
提交操作检查
- Was the work item branch name retrieved successfully?
- Were files staged with ?
git add - Did succeed with exit code 0?
git commit - Did succeed with exit code 0?
git push
- 是否已成功获取工作项分支名称?
- 是否已通过暂存文件?
git add - 是否成功且退出码为0?
git commit - 是否成功且退出码为0?
git push
Update Operation Checks
更新操作检查
- Was work item identifier provided (name or ID)?
- Was at least one update field provided (subject, description, or status)?
- If status was updated, was it a valid value ("In Progress" or "Ready to Promote")?
- Was the updated work item returned in JSON?
- 是否已提供工作项标识符(名称或ID)?
- 是否已提供至少一个更新字段(主题、描述或状态)?
- 若更新了状态,是否为有效值("In Progress"或"Ready to Promote")?
- 是否已返回更新后的工作项JSON?
Create-Review Operation Checks
创建审查操作检查
- Was work item identifier provided (name or ID)?
- Was a PR URL returned in JSON output?
- Was the PR creation confirmed?
- 是否已提供工作项标识符(名称或ID)?
- JSON输出是否返回了PR链接?
- 是否已确认PR创建成功?
Reference File Index
参考文件索引
| File | When to read |
|---|---|
| When you need detailed CLI flag documentation, JSON output schemas, or error handling patterns |
| When the user's request matches a common pattern (bulk updates, reassignment, idempotent creation, sequential transitions) |
| 文件 | 阅读时机 |
|---|---|
| 需要详细CLI参数文档、JSON输出模式或错误处理模式时 |
| 用户请求匹配常见模式(批量更新、重新分配、幂等创建、顺序转换)时 |