You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

合并JIRA项目后如何映射新旧IssueKey适配自动化测试

Hey Florian, let's work through this JIRA issue key mapping problem so you don't have to update your test suite's issue key list. Here are actionable solutions based on your initial ideas and some additional approaches:

Solutions to Avoid Updating Test Suite Issue Keys

1. Fix the "old IssueKey in SQL" problem with database joins

You're right that JQL lets you search by old issue keys, but direct SQL inserts can't use them—because JIRA only stores the current issue key in the core jiraissue table. The old keys live in change history tables.

You can work around this by first querying the new key using the old one, then using that new key in your INSERT. Here's an example SQL query (adjust syntax for your JIRA database, e.g., PostgreSQL vs MySQL):

-- Get new issue key from old key
SELECT p.pkey || '-' || j.issuenum AS new_issue_key
FROM jiraissue j
JOIN project p ON j.project = p.id
JOIN changeitem ci ON j.id = ci.issueid
JOIN changegroup cg ON ci.groupid = cg.id
WHERE ci.field = 'key'
AND ci.oldstring = 'YOUR-OLD-ISSUE-KEY';

Integrate this lookup into your test automation script: run the query first to get the new key, then execute your INSERT with that value.

2. Generate a reliable old-to-new key mapping (better than manual activity exports)

Instead of manually exporting activity logs, use these more scalable methods:

  • JIRA REST API batch extraction:
    1. Use JQL to filter all issues with changed keys: issuekey changed
    2. For each issue in the results, call the /rest/api/3/issue/{issueIdOrKey}/changelog endpoint
    3. Parse the response to extract the old and new key values, then build a mapping file (JSON/CSV)
  • JQL search export:
    Run the same issuekey changed JQL search, export results as CSV, and include the "Change History" field. Use a simple script (Python, Excel macro) to parse the export and extract key pairs.

3. Add a mapping layer to your test automation (one-time setup)

Once you have the full old-to-new key mapping, save it as a config file (e.g., key-mapping.json). Then modify your test script to include a helper function: when you need to update a test result, pass the old key to the function, which returns the new key from the config. This way, you never have to touch the issue key list in your test suite—just update the config if any new key changes happen.

Bonus: Long-term workaround with custom fields

If you need ongoing access to old keys, add a custom JIRA field (e.g., "Old Issue Key") and bulk-populate it with the original keys for all merged issues. Then your SQL can directly reference this field to find the correct issue, no change history joins needed.

内容的提问来源于stack exchange,提问作者WorkFlo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:23:16