diff --git a/.devops/monitor.py b/.devops/monitor.py index 052bf2f..e1207a6 100644 --- a/.devops/monitor.py +++ b/.devops/monitor.py @@ -325,6 +325,15 @@ class GitMonitor: try: # 1. 更新主仓库和子模块 if not self.update_main_repo(): + # 发送 Git 更新失败通知 + if self.dingtalk_notifier: + duration = time.time() - start_time + self.dingtalk_notifier.send_build_failure( + repo_name=repo_name, + branch=self.global_branch, + commit_hash=commit_hash, + error_msg="Git 仓库更新失败(主仓库或子模块)" + ) return False # 获取子仓库的 commit message @@ -358,6 +367,15 @@ class GitMonitor: # 2. 初始化基础设施 if not self.init_infrastructure(): + # 发送基础设施初始化失败通知 + if self.dingtalk_notifier: + duration = time.time() - start_time + self.dingtalk_notifier.send_build_failure( + repo_name=repo_name, + branch=self.global_branch, + commit_hash=commit_hash, + error_msg="基础设施初始化失败(MySQL/Redis/Nacos等)" + ) return False # 3. 根据项目类型执行打包 @@ -462,6 +480,16 @@ class GitMonitor: Logger.error(f"✗ 部署失败: {repo_config['name']}") except Exception as e: Logger.error(f"处理仓库异常 {repo_config['name']}: {e}") + # 发送异常通知 + if self.dingtalk_notifier: + commit_hash = self.last_commits.get(repo_config['name'], 'unknown') + self.dingtalk_notifier.send_build_failure( + repo_name=repo_config['name'], + branch=self.global_branch, + commit_hash=commit_hash, + error_msg=f"处理仓库时发生异常: {str(e)}", + at_all=True + ) def run(self): """持续监听运行"""