rhdh-jira-link
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseJira PR / MR links
Jira PR/MR 关联工具
Zero-token Node scripts for GitHub and GitLab: create the PR/MR, attach a
Jira remote Web link, post or update a structured comment, and optionally fill
empty issue fields.
Scripts live under this skill's directory. Resolve that path from the
installed skill root (agents already have it when reading this file):
scripts/bash
SKILL="$(cd "$(dirname "$0")" && pwd)" # or the absolute path to this skill root
node "$SKILL/scripts/create-pr-mr.js" …
node "$SKILL/scripts/link-pr-mr.js" …Another skill that needs the link step invokes by name and
lets this skill run its own scripts; it never calls into this directory by path.
/rhdh-jira-link适用于GitHub和GitLab的零令牌Node脚本:创建PR/MR、附加Jira远程网页链接、发布或更新结构化评论,还可选择性填充空的问题字段。
脚本位于本skill的目录下。可从已安装的skill根目录解析该路径(Agent读取此文件时已具备该路径):
scripts/bash
SKILL="$(cd "$(dirname "$0")" && pwd)" # 或指向本skill根目录的绝对路径
node "$SKILL/scripts/create-pr-mr.js" …
node "$SKILL/scripts/link-pr-mr.js" …其他需要关联步骤的skill可通过名称调用,由本skill运行自身脚本;切勿通过路径直接调用此目录下的文件。
/rhdh-jira-linkPreferred: one-shot create (create-pr-mr.js
)
create-pr-mr.js推荐方式:一键创建(create-pr-mr.js
)
create-pr-mr.jsAfter the feature branch is committed:
bash
node "$SKILL/scripts/create-pr-mr.js" \
--issue RHIDP-12345 \
--title 'fix: short summary' \
--target main \
--body "$(cat <<'EOF'功能分支提交完成后:
bash
node "$SKILL/scripts/create-pr-mr.js" \
--issue RHIDP-12345 \
--title 'fix: short summary' \
--target main \
--body "$(cat <<'EOF'Summary
Summary
- …
- …
Test plan
Test plan
- …
Generated-by: cursor
EOF
)"
1. `git push -u origin HEAD` (unless `--no-push`)
2. Detects GitHub vs GitLab from `origin`
3. Runs `gh pr create` or `glab mr create`
4. Runs `link-pr-mr.js link` (unless `--no-link`). Missing Jira auth is an
error; pass `--no-link` to skip linking.
5. Opens the diffs page (unless `--no-open`)
Flags: `--draft`, `--no-push`, `--no-link`, `--no-open`, `--no-defaults`,
`--no-comment`, `--no-jira-ref`, `--host github|gitlab`.- …
Generated-by: cursor
EOF
)"
1. 执行`git push -u origin HEAD`(除非指定`--no-push`)
2. 从`origin`自动检测是GitHub还是GitLab
3. 运行`gh pr create`或`glab mr create`
4. 运行`link-pr-mr.js link`(除非指定`--no-link`)。若缺少Jira认证会报错;可通过`--no-link`跳过关联步骤
5. 打开差异页面(除非指定`--no-open`)
可用参数:`--draft`, `--no-push`, `--no-link`, `--no-open`, `--no-defaults`, `--no-comment`, `--no-jira-ref`, `--host github|gitlab`。Auth
认证方式
Either works (same token either way):
- +
JIRA_API_TOKEN/logininserver, or~/.config/.jira/.config.yml - (
.jira-token) next toemail:token— the same credentialacliuses. Invoke/rhdh-jira-apiby name for the authoritative auth setup instead of duplicating it here./rhdh-jira-api
create-pr-mr.jsRef: https://redhat.atlassian.net/browse/KEYGenerated-by: cursorRef:community-plugins--no-jira-ref以下两种方式均可使用(两种方式使用相同令牌):
- 设置,并在
JIRA_API_TOKEN中配置~/.config/.jira/.config.yml/login;或server - 在旁放置
acli文件(格式为.jira-token)——与email:token使用的凭据相同。建议通过名称调用/rhdh-jira-api进行权威认证设置,而非在此处重复配置。/rhdh-jira-api
当PR/MR正文中缺少和时,会自动追加。对于远程仓库(或指定时),会跳过Jira的行,以避免该仓库的Git历史/PR文本中出现Jira浏览URL。
Ref: https://redhat.atlassian.net/browse/KEYGenerated-by: cursorcreate-pr-mr.jscommunity-plugins--no-jira-refRef:Link-only: link-pr-mr.js
link-pr-mr.js仅关联:link-pr-mr.js
link-pr-mr.jsWhen a PR/MR already exists:
bash
node "$SKILL/scripts/link-pr-mr.js" link \
--issue RHIDP-12345 \
--url 'https://gitlab.cee.redhat.com/rhidp/example/-/merge_requests/817' \
--title 'example #817: fix: short summary' \
--host gitlab- optional; inferred from URL when omitted.
--host - skips In Progress + metadata fills (Web link + comment still run).
--no-defaults - skips the Jira comment.
--no-comment - If a comment already mentions the PR/MR URL, it is updated in place (comments are paginated).
当PR/MR已存在时:
bash
node "$SKILL/scripts/link-pr-mr.js" link \
--issue RHIDP-12345 \
--url 'https://gitlab.cee.redhat.com/rhidp/example/-/merge_requests/817' \
--title 'example #817: fix: short summary' \
--host gitlab- 为可选参数;若省略,会从URL自动推断
--host - 会跳过“进行中”状态设置和元数据填充(但仍会执行网页链接和评论步骤)
--no-defaults - 会跳过Jira评论
--no-comment - 若已有评论提及该PR/MR URL,会就地更新该评论(评论支持分页)
RHDHPLAN → RHIDP auto-move
RHDHPLAN → RHIDP 自动迁移
If the linked issue is an Epic, Story, or Task in RHDHPLAN,
moves it to RHIDP (same issue type) via the Jira bulk-move API, then
continues Web link / defaults / comment on the new key. Features and other
RHDHPLAN types are left alone.
linkStdout includes and the post-move key.
move: …issue:Comment shape (only newly set fields; omit values):
keptPR/MR:
* example #817: fix: short summary
Adjusted fields:
* Priority: Normal
* Status: In ProgressVisible link text matches the Web link title ().
repo #N: <title>若关联的问题是RHDHPLAN项目中的Epic、Story或Task,命令会通过Jira批量迁移API将其迁移至RHIDP项目(保持原问题类型),然后在新的问题键上继续执行网页链接/默认值填充/评论步骤。RHDHPLAN中的其他类型(如Feature)则不会被迁移。
link标准输出会包含和迁移后的键。
move: …issue:评论格式(仅包含新设置的字段;省略的值):
保留PR/MR:
* example #817: fix: short summary
已调整字段:
* 优先级:正常
* 状态:进行中可见的链接文本与网页链接标题一致()。
repo #N: <title>Mark merged
标记为已合并
bash
node "$SKILL/scripts/link-pr-mr.js" mark-merged --issue RHIDP-12345Prefixes Web link titles with . Does not re-apply defaults/comment.
Stdout lists each title and its PR/MR URL (indented under the title).
[x] merged:mark-mergedghglabwarn:--hostnamegitlab.cee.redhat.comglabhost: gitlab.cee.redhat.com~/.config/glab-cli/config.ymlWhen summarizing to the user, use markdown links ().
[<title>](<url>)bash
node "$SKILL/scripts/link-pr-mr.js" mark-merged --issue RHIDP-12345在网页链接标题前添加前缀。不会重新应用默认值/评论。
[x] merged:标准输出会列出每个标题及其PR/MR URL(URL缩进显示在标题下方)。
mark-mergedghglabwarn:--hostnamegitlab.cee.redhat.com~/.config/glab-cli/config.ymlglabhostgitlab.cee.redhat.com向用户总结时,请使用Markdown链接格式:。
[<标题>](<URL>)Title format (for link --title
)
link --titlelink --title
的标题格式
link --title<repo-short-name> #<id>: <full PR/MR title>Merged:
[x] merged: <repo-short-name> #<id>: <full PR/MR title><repo-short-name> #<id>: <完整PR/MR标题>已合并的格式:
[x] merged: <repo-short-name> #<id>: <完整PR/MR标题>Defaults link
applies (only if empty)
linklink
命令应用的默认值(仅当字段为空时)
linkNo built-in team/assignee values. First run with defaults enabled requires a
config file (or env/CLI). Missing keys error when applying defaults; the Web
link and comment still succeed with .
--no-defaultsbash
mkdir -p ~/.config/rhdh-jira-link
cp "$SKILL/config.example.json" ~/.config/rhdh-jira-link/config.json无内置团队/经办人值。首次启用默认值运行时需要配置文件(或环境变量/命令行参数)。应用默认值时若缺少配置键会报错;但通过仍可成功执行网页链接和评论步骤。
--no-defaultsbash
mkdir -p ~/.config/rhdh-jira-link
cp "$SKILL/config.example.json" ~/.config/rhdh-jira-link/config.jsonedit assigneeEmail, teamId, teamName, boardId, …
编辑 assigneeEmail、teamId、teamName、boardId 等字段
Also accepted: `$JIRA_PR_MR_CONFIG` or `$SKILL/config.local.json`
(keep personal email out of the repo).
Precedence: **CLI > env > config file > Jira CLI hints** (`login` / `board.id`
from `~/.config/.jira/.config.yml` may fill assignee/board only).
| Field | Required when applying defaults |
|-------|----------------------------------|
| `assigneeEmail` | yes (or Jira `login` email) |
| `teamId` / `teamName` | yes, or set either to `NONE` to skip team **and** sprint |
| `boardId` | yes (or jira CLI `board.id`), unless team/sprint skipped via `NONE` |
| `storyPoints` | yes |
| `priorityName` | yes (only fills when priority is empty) |
| `storyPointsField` | yes |
| `teamField` / `sprintField` | yes, unless team/sprint skipped via `NONE` |
| Status | → **In Progress** unless already In Progress / Review / Closed |
Skip all defaults: `--no-defaults` or `JIRA_PR_MR_APPLY_DEFAULTS=0`.
Skip only team + sprint (still set points / assignee / priority / In Progress):
```json
"teamName": "NONE",
"teamId": "NONE"
也可通过`$JIRA_PR_MR_CONFIG`环境变量或`$SKILL/config.local.json`文件配置(请勿将个人邮箱提交到仓库)。
优先级:**命令行参数 > 环境变量 > 配置文件 > Jira CLI提示**(`~/.config/.jira/.config.yml`中的`login`/`board.id`仅可填充经办人/看板字段)。
| 字段 | 应用默认值时是否必填 |
|-------|----------------------------------|
| `assigneeEmail` | 是(或使用Jira的`login`邮箱) |
| `teamId` / `teamName` | 是,或设置其中一个为`NONE`以跳过团队**和**迭代 |
| `boardId` | 是(或使用Jira CLI的`board.id`),除非通过`NONE`跳过团队/迭代 |
| `storyPoints` | 是 |
| `priorityName` | 是(仅当优先级为空时填充) |
| `storyPointsField` | 是 |
| `teamField` / `sprintField` | 是,除非通过`NONE`跳过团队/迭代 |
| 状态 | → **进行中**,除非已处于进行中/评审/关闭状态 |
跳过所有默认值:使用`--no-defaults`或设置`JIRA_PR_MR_APPLY_DEFAULTS=0`。
仅跳过团队+迭代(仍设置故事点/经办人/优先级/进行中状态):
```json
"teamName": "NONE",
"teamId": "NONE"Relationship to /rhdh-pr-create
/rhdh-pr-create与/rhdh-pr-create
的关系
/rhdh-pr-create/rhdh-pr-createOnce has created a PR, it hands the URL and title back and
this skill runs the link step with , leaving
free to transition the issue to Review (see
references/raise-pr-integration.md).
/rhdh-pr-create--no-defaults/rhdh-pr-create/rhdh-pr-create当创建PR后,会返回URL和标题,本skill会使用执行关联步骤,让可自由将问题状态转换为评审中(详见references/raise-pr-integration.md)。
/rhdh-pr-create--no-defaults/rhdh-pr-createAgent checklist
Agent检查清单
- Resolve Jira key. Ask if missing (unless user skipped Jira).
- Commit on a feature branch. Put the Jira browse URL and in the PR/MR body (
Generated-by: cursorappends them when missing; skipscreate-pr-mr.jsfor community-plugins).Ref: - Run once. Report
create-pr-mr.js/url:/diffs:/browserOpened:from its stdout (jiraLink:orbrowserOpened: truemeans the open step is already done).--no-open - Fallback: raw create → run , then open diffs yourself once.
link-pr-mr.js - For mark-merged: .
link-pr-mr.js mark-merged --issue KEY - In user-facing summaries, link PR/MRs as .
[<title>](<url>)
- 解析Jira问题键。若缺失则询问用户(除非用户跳过Jira关联)。
- 在功能分支上提交代码。将Jira浏览URL和添加到PR/MR正文中(
Generated-by: cursor会在缺失时自动追加;对于community-plugins仓库会跳过create-pr-mr.js行)。Ref: - 运行一次****。报告其标准输出中的
create-pr-mr.js/url:/diffs:/browserOpened:信息(jiraLink:或使用browserOpened: true表示已完成打开页面步骤)。--no-open - 备选方案:手动创建PR/MR → 运行,然后自行打开差异页面一次。
link-pr-mr.js - 标记已合并:使用。
link-pr-mr.js mark-merged --issue KEY - 在面向用户的总结中,使用格式链接PR/MR。
[<标题>](<URL>)
Every run here is an external write
此处的每次运行均为外部写入操作
Creating a PR/MR, writing a Jira Web link, posting a comment, moving an issue to
another project, and filling default fields all change something outside the
session. Invoke and follow it before the first command:
one script invocation can perform several of these at once, so state them as one
set — push, create, link, comment, defaults — and get a single approval covering
all of them.
/mutation-gate创建PR/MR、写入Jira网页链接、发布评论、将问题迁移至其他项目、填充默认字段等操作都会修改会话之外的内容。在执行第一个命令前,请调用并遵循其要求:一次脚本调用可能同时执行多项此类操作,因此需将这些操作(推送、创建、关联、评论、默认值填充)作为一组进行说明,并获取一次涵盖所有操作的审批。
/mutation-gateCompletion
完成标准
Complete when the answer names the PR/MR URL and diffs link, the Jira key it was
linked to — including the post-move key when an RHDHPLAN Epic, Story, or Task
moved to RHIDP — the Web link title, whether the comment was posted or updated,
which default fields were newly set, and every line the scripts printed.
Report the fields the script left alone as kept, never as set. A Web link that
succeeded followed by a defaults update that errored is a partial link, so say
which half landed.
warn:当回复中包含以下信息时,视为完成:PR/MR的URL和差异链接、关联的Jira问题键——若RHDHPLAN的Epic、Story或Task迁移至RHIDP,需包含迁移后的问题键、网页链接标题、评论是已发布还是已更新、新设置了哪些默认字段,以及脚本打印的所有行。将脚本未修改的字段报告为“保留”,而非“设置”。若网页链接关联成功但默认值更新报错,则视为部分关联,需说明哪部分已完成。
warn: