rhdh-jira-link

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Jira 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
scripts/
directory. Resolve that path from the installed skill root (agents already have it when reading this file):
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
/rhdh-jira-link
by name and lets this skill run its own scripts; it never calls into this directory by path.
适用于GitHub和GitLab的零令牌Node脚本:创建PR/MR、附加Jira远程网页链接、发布或更新结构化评论,还可选择性填充空的问题字段。
脚本位于本skill的
scripts/
目录下。可从已安装的skill根目录解析该路径(Agent读取此文件时已具备该路径):
bash
SKILL="$(cd "$(dirname "$0")" && pwd)"   # 或指向本skill根目录的绝对路径
node "$SKILL/scripts/create-pr-mr.js" …
node "$SKILL/scripts/link-pr-mr.js" …
其他需要关联步骤的skill可通过名称调用
/rhdh-jira-link
,由本skill运行自身脚本;切勿通过路径直接调用此目录下的文件。

Preferred: one-shot create (
create-pr-mr.js
)

推荐方式:一键创建(
create-pr-mr.js

After 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):
  1. JIRA_API_TOKEN
    +
    login
    /
    server
    in
    ~/.config/.jira/.config.yml
    , or
  2. .jira-token
    (
    email:token
    ) next to
    acli
    — the same credential
    /rhdh-jira-api
    uses. Invoke
    /rhdh-jira-api
    by name for the authoritative auth setup instead of duplicating it here.
create-pr-mr.js
appends
Ref: https://redhat.atlassian.net/browse/KEY
and
Generated-by: cursor
to the PR/MR body when missing. It skips the Jira
Ref:
line for
community-plugins
remotes (or when
--no-jira-ref
is set) so that repo stays free of Jira browse URLs in git history / PR text.
以下两种方式均可使用(两种方式使用相同令牌):
  1. 设置
    JIRA_API_TOKEN
    ,并在
    ~/.config/.jira/.config.yml
    中配置
    login
    /
    server
    ;或
  2. acli
    旁放置
    .jira-token
    文件(格式为
    email:token
    )——与
    /rhdh-jira-api
    使用的凭据相同。建议通过名称调用
    /rhdh-jira-api
    进行权威认证设置,而非在此处重复配置。
当PR/MR正文中缺少
Ref: https://redhat.atlassian.net/browse/KEY
Generated-by: cursor
时,
create-pr-mr.js
会自动追加。对于
community-plugins
远程仓库(或指定
--no-jira-ref
时),会跳过Jira的
Ref:
行,以避免该仓库的Git历史/PR文本中出现Jira浏览URL。

Link-only:
link-pr-mr.js

仅关联:
link-pr-mr.js

When 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
  • --host
    optional; inferred from URL when omitted.
  • --no-defaults
    skips In Progress + metadata fills (Web link + comment still run).
  • --no-comment
    skips the Jira 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
  • --host
    为可选参数;若省略,会从URL自动推断
  • --no-defaults
    会跳过“进行中”状态设置和元数据填充(但仍会执行网页链接和评论步骤)
  • --no-comment
    会跳过Jira评论
  • 若已有评论提及该PR/MR URL,会就地更新该评论(评论支持分页)

RHDHPLAN → RHIDP auto-move

RHDHPLAN → RHIDP 自动迁移

If the linked issue is an Epic, Story, or Task in RHDHPLAN,
link
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.
Stdout includes
move: …
and the post-move
issue:
key.
Comment shape (only newly set fields; omit
kept
values):
PR/MR:
* example #817: fix: short summary

Adjusted fields:
* Priority: Normal
* Status: In Progress
Visible link text matches the Web link title (
repo #N: <title>
).
若关联的问题是RHDHPLAN项目中的EpicStoryTask
link
命令会通过Jira批量迁移API将其迁移至RHIDP项目(保持原问题类型),然后在新的问题键上继续执行网页链接/默认值填充/评论步骤。RHDHPLAN中的其他类型(如Feature)则不会被迁移。
标准输出会包含
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-12345
Prefixes Web link titles with
[x] merged:
. Does not re-apply defaults/comment. Stdout lists each title and its PR/MR URL (indented under the title).
mark-merged
checks merge status via
gh
/
glab
. Failed checks print a
warn:
line. For GitLab remotelinks it passes
--hostname
from the URL (e.g.
gitlab.cee.redhat.com
), so CEE MRs resolve against the right host. Prefer
glab
default
host: gitlab.cee.redhat.com
in
~/.config/glab-cli/config.yml
for day-to-day CEE work.
When 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-merged
会通过
gh
/
glab
检查合并状态。检查失败会打印
warn:
行。对于GitLab远程链接,会从URL中提取
--hostname
(例如
gitlab.cee.redhat.com
),确保CEE的MR能正确解析到对应主机。日常CEE工作中,建议在
~/.config/glab-cli/config.yml
中将
glab
的默认
host
设置为
gitlab.cee.redhat.com
向用户总结时,请使用Markdown链接格式:
[<标题>](<URL>)

Title format (for
link --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)

link
命令应用的默认值(仅当字段为空时)

No 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-defaults
.
bash
mkdir -p ~/.config/rhdh-jira-link
cp "$SKILL/config.example.json" ~/.config/rhdh-jira-link/config.json
无内置团队/经办人值。首次启用默认值运行时需要配置文件(或环境变量/命令行参数)。应用默认值时若缺少配置键会报错;但通过
--no-defaults
仍可成功执行网页链接和评论步骤。
bash
mkdir -p ~/.config/rhdh-jira-link
cp "$SKILL/config.example.json" ~/.config/rhdh-jira-link/config.json

edit 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
owns the rhdh-plugins / community-plugins monorepo PR flow (build, changesets, recordings). This skill owns the Jira Web link + comment (and optional defaults) for any repo. Invoke it by name; do not read or run its files.
Once
/rhdh-pr-create
has created a PR, it hands the URL and title back and this skill runs the link step with
--no-defaults
, leaving
/rhdh-pr-create
free to transition the issue to Review (see references/raise-pr-integration.md).
/rhdh-pr-create
负责rhdh-plugins/community-plugins单体仓库的PR流程(构建、变更集、录制)。本skill负责任意仓库的Jira网页链接+评论(及可选默认值填充)。请通过名称调用本skill;请勿读取或运行其文件。
/rhdh-pr-create
创建PR后,会返回URL和标题,本skill会使用
--no-defaults
执行关联步骤,让
/rhdh-pr-create
可自由将问题状态转换为评审中(详见references/raise-pr-integration.md)。

Agent checklist

Agent检查清单

  1. Resolve Jira key. Ask if missing (unless user skipped Jira).
  2. Commit on a feature branch. Put the Jira browse URL and
    Generated-by: cursor
    in the PR/MR body (
    create-pr-mr.js
    appends them when missing; skips
    Ref:
    for community-plugins).
  3. Run
    create-pr-mr.js
    once. Report
    url:
    /
    diffs:
    /
    browserOpened:
    /
    jiraLink:
    from its stdout (
    browserOpened: true
    or
    --no-open
    means the open step is already done).
  4. Fallback: raw create → run
    link-pr-mr.js
    , then open diffs yourself once.
  5. For mark-merged:
    link-pr-mr.js mark-merged --issue KEY
    .
  6. In user-facing summaries, link PR/MRs as
    [<title>](<url>)
    .
  1. 解析Jira问题键。若缺失则询问用户(除非用户跳过Jira关联)。
  2. 在功能分支上提交代码。将Jira浏览URL和
    Generated-by: cursor
    添加到PR/MR正文中(
    create-pr-mr.js
    会在缺失时自动追加;对于community-plugins仓库会跳过
    Ref:
    行)。
  3. 运行一次**
    create-pr-mr.js
    **。报告其标准输出中的
    url:
    /
    diffs:
    /
    browserOpened:
    /
    jiraLink:
    信息(
    browserOpened: true
    或使用
    --no-open
    表示已完成打开页面步骤)。
  4. 备选方案:手动创建PR/MR → 运行
    link-pr-mr.js
    ,然后自行打开差异页面一次。
  5. 标记已合并:使用
    link-pr-mr.js mark-merged --issue KEY
  6. 在面向用户的总结中,使用
    [<标题>](<URL>)
    格式链接PR/MR。

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
/mutation-gate
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.
创建PR/MR、写入Jira网页链接、发布评论、将问题迁移至其他项目、填充默认字段等操作都会修改会话之外的内容。在执行第一个命令前,请调用
/mutation-gate
并遵循其要求:一次脚本调用可能同时执行多项此类操作,因此需将这些操作(推送、创建、关联、评论、默认值填充)作为一组进行说明,并获取一次涵盖所有操作的审批。

Completion

完成标准

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
warn:
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.
当回复中包含以下信息时,视为完成:PR/MR的URL和差异链接、关联的Jira问题键——若RHDHPLAN的Epic、Story或Task迁移至RHIDP,需包含迁移后的问题键、网页链接标题、评论是已发布还是已更新、新设置了哪些默认字段,以及脚本打印的所有
warn:
行。将脚本未修改的字段报告为“保留”,而非“设置”。若网页链接关联成功但默认值更新报错,则视为部分关联,需说明哪部分已完成。