ChatGPT软件基础设施AI 评分 · 74/100AI 辅助编辑·未发现明显提示词注入风险n8n.io

GitHub Issues 自动同步 Jira:GPT-4o 分析 bug 并通知团队

接收 GitHub Webhook → GPT-4o 分析严重度与分类 → 创建 Jira 工单 → 并行通知 Slack/Discord/GitHub

经验丰富步骤流程提示词贴士
给谁
需要自动处理 GitHub bug 报告的开发团队、开源项目维护者或 DevOps 工程师
你会得到
GitHub 新建 issue 自动触发 AI 分析,生成带严重度、分类、复现步骤、预估工时的 Jira 工单,并同步回评 GitHub issue、推送 Slack/Discord 告警
你需要
n8n · webhook · code · openai · github · slack

硬约束

前置条件:n8n 实例;GitHub 仓库管理员权限;Jira Software Cloud 及 API Token;OpenAI API key(GPT-4o 访问权限);Slack 工作区或 Discord 服务器(可选)。需自定义:开发者邮箱映射、JIRA_PROJECT_KEY、Slack 频道名、Discord webhook URL、Jira 域名。

他们做了什么

该 n8n 模板展示了一个完整的自动化工作流:通过 GitHub Webhook 捕获新建 issue,经 IF 过滤仅处理 opened 事件,用 Code 节点提取 issue 上下文和提及文件,调用 GPT-4o 分析 bug 严重度、分类、复现步骤、根因、优先级、复杂度、推荐开发者及预估工时,再经 Code 节点解析映射为 Jira 字段,创建 Jira Bug 工单,最后并行执行 GitHub 评论回写、Slack 富文本告警、Discord webhook 告警,并以 JSON 响应 GitHub Webhook。

效果如何

来源作者声称:每 issue 处理时间从 20 分钟降至 2 分钟(提速 90%),分析一致性 100%,零遗漏通知,每月处理 50 个 bug 可节省约 $685(author_report,未实测)。

值得知道

1. 开发者邮箱映射必须自定义,模板中默认使用 [email protected] 占位符。2. Slack 频道名使用 dev-alerts(不加 #),Discord 需完整 webhook URL。3. Jira 域名、项目 key、issue type 'Bug' 需与实例匹配。4. GPT-4o 调用成本约 $0.01-0.03/issue。5. 若 GPT 返回非标准 JSON,解析节点有硬编码回退值,但生产环境建议增加日志告警。6. 模板含 ROI 计算和定制建议(按严重度路由、多仓库支持、邮件通知等),属作者建议,非核心流程必需。

步骤

  1. 配置 GitHub Webhook 触发器

    在 n8n 中激活工作流,复制 Webhook 节点的 URL。前往 GitHub 仓库 Settings → Webhooks → Add webhook,粘贴 URL,Content-type 选 application/json,Events 勾选 Issues,保存。测试:在仓库新建一个 issue。

  2. 过滤仅处理新建 Issues

    添加 IF 节点,条件为 action = "opened"(通过 {{$json.action}} 判断)。TRUE 继续执行,FALSE 终止。防止 issue 编辑、打标签、评论等操作重复创建 Jira 工单。

  3. 提取 Issue 上下文

    使用 Code 节点执行 JavaScript,从 GitHub payload 中提取 issue 编号、标题、描述、报告者、标签、URL、仓库信息,并用正则匹配正文中提到的代码文件(.js/.py/.ts/.jsx/.tsx/.java/.go/.rb/.php/.cpp/.c/.css/.html)。输出结构化对象供下游使用。 节点代码(Code): ```js const issue = $input.item.json.issue; const repo = $input.item.json.repository; const fileRegex = /`([^`]*\.(js|py|ts|jsx|tsx|java|go|rb|php|cpp|c|css|html))`/g; const mentionedFiles = []; let match; if (issue.body) { while ((match = fileRegex.exec(issue.body)) !== null) { mentionedFiles.push(match[1]); } } return { issueNumber: issue.number, title: issue.title, description: issue.body || "No description provided", reporter: issue.user.login, reporterAvatar: issue.user.avatar_url, labels: issue.labels.map(l => l.name).join(", ") || "none", url: issue.html_url, createdAt: issue.created_at, mentionedFiles: mentionedFiles.join(", ") || "No files mentioned", repositoryName: repo.full_name, repositoryOwner: repo.owner.login, repositoryRepo: repo.name }; ```

  4. GPT-4o 分析 Bug

    使用 OpenAI 节点调用 GPT-4o(model: gpt-4o, maxTokens: 1000, temperature: 0.3)。将上一步提取的 issue 标题、描述、标签、提及文件、仓库名传入提示词,要求返回严格 JSON 格式,包含严重度、分类、复现步骤、根因、优先级、复杂度、推荐开发者类型、预估工时。

    运行提示词 · 来源原文。GPT-4o Bug Analysis 节点的 text 字段

    =Analyze this GitHub issue and provide a structured response in valid JSON format:
    
    **Issue Title:** {{$json.title}}
    **Description:** {{$json.description}}
    **Labels:** {{$json.labels}}
    **Mentioned Files:** {{$json.mentionedFiles}}
    **Repository:** {{$json.repositoryName}}
    
    Provide your analysis in this exact JSON structure:
    {
      "bugSeverity": "Critical|High|Medium|Low",
      "category": "Backend|Frontend|Database|API|UI|Performance|Security|Infrastructure",
      "reproductionSteps": "Clear numbered steps to reproduce",
      "potentialRootCause": "Brief technical analysis",
      "suggestedPriority": "P0|P1|P2|P3",
      "estimatedComplexity": "Simple|Medium|Complex",
      "recommendedDeveloper": "backend-dev|frontend-dev|fullstack-dev|devops",
      "estimatedHours": "number between 1-40"
    }
    
    Respond with ONLY the JSON object, no additional text.
  5. 解析 GPT 响应并映射数据

    使用 Code 节点解析 GPT-4o 返回的 JSON(含错误回退:解析失败时默认 Medium/General/P2/Medium/fullstack-dev/8h)。将 recommendedDeveloper 映射为实际邮箱地址,suggestedPriority 映射为 Jira 优先级(P0→Highest, P1→High, P2→Medium, P3→Low),生成 jiraLabels 数组。⚠️ 必须自定义 developerMapping 中的邮箱。 节点代码(Code): ```js const issueData = $('Extract Issue Context').item.json; const gptResponse = $input.item.json.text; let analysis; try { analysis = JSON.parse(gptResponse); } catch (error) { analysis = { bugSeverity: "Medium", category: "General", reproductionSteps: "See original issue", potentialRootCause: "Requires investigation", suggestedPriority: "P2", estimatedComplexity: "Medium", recommendedDeveloper: "fullstack-dev", estimatedHours: 8 }; } const developerMapping = { "backend-dev": "[email protected]", "frontend-dev": "[email protected]", "fullstack-dev": "[email protected]", "devops": "[email protected]" }; const priorityMapping = { "P0": "Highest", "P1": "High", "P2": "Medium", "P3": "Low" }; return { ...issueData, bugSeverity: analysis.bugSeverity, category: analysis.category, reproductionSteps: analysis.reproductionSteps, potentialRootCause: analysis.potentialRootCause, suggestedPriority: analysis.suggestedPriority, estimatedComplexity: analysis.estimatedComplexity, estimatedHours: analysis.estimatedHours, recommendedDeveloper: analysis.recommendedDeveloper, assignedDeveloper: developerMapping[analysis.recommendedDeveloper] || "[email protected]", jiraLabels: [analysis.category, analysis.bugSeverity], jiraPriority: priorityMapping[analysis.suggestedPriority] || "Medium" }; ```

  6. 创建 Jira 工单

    使用 Jira 节点创建 Bug 类型工单。填写 project 为 YOUR_JIRA_PROJECT_KEY,summary 格式为 [GitHub #{issueNumber}] {title},description 包含报告者、GitHub 链接、原始描述、AI 分析摘要(严重度、分类、复杂度、预估工时、提及文件、复现步骤、根因)。additionalFields 设置 labels、assignee、priority。需替换 your-company.atlassian.net 为实际域名。

  7. 并行通知 GitHub/Slack/Discord

    Jira 工单创建后,三个分支并行执行:1) GitHub 节点在原始 issue 添加评论,包含 Jira 链接、AI 分析摘要、指派开发者、预估工时;2) Slack 节点发送富文本消息到 dev-alerts 频道,含标题、严重度、分类、优先级、指派者、预估工时、根因摘要及 GitHub/Jira 查看按钮;3) Discord 节点通过 webhook 发送 Markdown 格式告警。需配置对应凭证和频道/webhook URL。

  8. 返回 Webhook 响应

    使用 Respond to Webhook 节点返回 JSON:{"status": "success", "message": "Bug report processed", "jiraTicket": $json.key}。确认处理成功,防止 GitHub 重试,可在 GitHub Settings → Webhooks → Recent Deliveries 查看日志。

可复制提示词

搭建指导 · 本站建议版本。搭建助手启动词:确认已具备 n8n 实例、GitHub/Jira/OpenAI 凭证,再按步骤导入 workflow JSON 并自定义映射

这一段是提示词,页面不会在这里插入广告。

先导入 workflow.json,再逐个节点配置凭证和自定义字段,最后测试新建 GitHub issue 触发全链路

来源

GitHub to Jira bug sync with GPT-4o analysis & team alerts · SheCodesFlow · n8n.io · 2025-10-03

留言与反馈

试过这个方法吗?分享效果、遇到的问题或改进建议。留言审核后公开,请勿填写敏感信息。

正在加载…

    相关用例