Skip to content
On this page

Jenkins 构建失败自动分析

概述

当 Jenkins trigger job 构建失败时,自动完成:

  1. 解析构建日志,定位失败根因(第一个 FAILURE 的 sub-job)
  2. 获取编译服务器 IP、workspace 路径、错误文件
  3. SSH 到编译服务器,fetch 完整 git 历史,git log 找到引入错误的 commit
  4. git show 获取 commit 作者、邮箱、时间、message、Change-Id
  5. 发送企业微信 webhook 通知
  6. 输出结构化分析报告

系统架构

Jenkins Trigger Job

       │ PostBuildScript (所有结果)

Hermes Webhook (jenkins-monitor)


解析 trigger consoleText
找第一个 FAILURE 的 sub-job


获取 sub-job consoleText
提取编译服务器 IP + workspace + 错误文件


SSH 到编译服务器
git fetch --depth=500 origin <branch>
git log -- <error_file>


git show <commit_hash>
提取作者/邮箱/message


企业微信 Webhook 通知