咨询Jira能否基于邮件内容自动分类问题并替代自动化Bug报告系统
Great question—this is a super common pain point when moving legacy bug tracking systems to Jira, and there are solid, scalable ways to replicate your existing workflow. Let’s break down how to tackle each of your core requirements:
1. Automated Project Routing (No Per-Project Inboxes)
You don’t need separate email addresses for each project. Jira gives you two primary ways to route bugs to the right project based on email content:
Option 1: Advanced Mail Handler Configuration (Native Jira)
Set up a single global inbox (e.g., bug-alerts@yourcompany.com) and configure a Mail Handler with regex-based project extraction:
- When creating/editing the Mail Handler, look for the "Project" field. Instead of picking a static project, use a regular expression to capture the project key from your email subject or body.
- Example: If your email subject follows
[System: PaymentService][Project: PAY] Unhandled Exception, use the regex\[Project: ([A-Z0-9]+)\]to capture thePAYproject key. Jira will automatically assign the issue to the matching project.
- Example: If your email subject follows
- This works for both Jira Cloud and Data Center/Server.
Option 2: Jira Automation Rules (More Flexibility)
Jira Automation (built into Cloud, available as a plugin for Server/Data Center) lets you build more dynamic routing logic:
- Trigger: "When an issue is created via email"
- Action: Add a "Parse data" step to extract the project key from the subject/body using regex.
- Conditional Action: Use the extracted key to update the issue’s project field. If no valid project key is found, route it to a default triage project or send an alert to your team.
2. Extracting Metadata to Populate Fields
Jira can absolutely pull specific details (class, method, line number, stack trace) from emails instead of treating the whole body as a single block.
Native Mail Handler Field Mapping
- For standard or custom fields, use the Mail Handler’s Field Mapping section. For example:
- Map the regex
Class: ([a-zA-Z0-9.]+)from the email body to a custom "Affected Class" field. - Capture
Method: ([a-zA-Z0-9_]+)to populate an "Affected Method" field. - Dump the entire stack trace into the issue’s Description field, or a dedicated "Stack Trace" custom field.
- Map the regex
Jira Automation for Complex Parsing
If your email format is structured (e.g., you can adjust it to include a JSON block at the top), Automation can parse this directly:
Example structured email snippet:
{ "project": "PAY", "class": "com.example.payment.PaymentProcessor", "method": "processTransaction", "line": 127, "stack_trace": "java.lang.IllegalArgumentException: Invalid amount..." }
- Use the "Parse JSON" action in Automation to extract each value and map it to the corresponding Jira field. This is far more reliable than regex for structured data.
3. Duplicate Bug Detection & Counting
To avoid duplicate issues and track repeat occurrences:
Native Automation + Issue Linking
- Create an Automation rule that triggers when a new bug is created via email:
- Use a "Search issues" action to find existing bugs that match key identifiers (e.g., same stack trace snippet, affected class/method).
- If a match is found:
- Link the new issue as a Duplicate of the existing one.
- Auto-close the new issue.
- Update a custom "Duplicate Count" field on the original bug (use the "Increment field" action to add 1).
ScriptRunner for Precision Duplicate Checks
If you need more granular matching (e.g., comparing the first 5 lines of a stack trace to avoid false negatives), use the ScriptRunner for Jira plugin:
- Write a Groovy script that runs when an email issue is created. The script can:
- Generate a hash of the stack trace (or key parts of it).
- Search Jira for existing bugs with the same hash.
- Update counts or link duplicates automatically.
Pro Tips for Reliability
- Standardize your email format: If you control the outgoing error emails, structure them with clear, consistent metadata sections (like the JSON example above). This makes parsing far more accurate than dealing with unstructured text.
- Test in a staging environment: Validate your Mail Handler/Automation rules with test emails before deploying to production to catch edge cases.
内容的提问来源于stack exchange,提问作者KlaymenDK

