fix(ci): 飞书通知返回错误码时也返回0,彻底不阻断CI流程
CI/CD Pipeline / Build Staging API Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Worker Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Web Image (push) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (push) Has been cancelled
CI/CD Pipeline / Production Browser E2E (push) Failing after 1531h7m57s
CI/CD Pipeline / Build Production Web Image (push) Failing after 1531h8m1s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 1531h8m1s
CI/CD Pipeline / Build Production API Image (push) Failing after 1531h8m1s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been skipped
CI/CD Pipeline / Unit Tests (push) Has been skipped
CI/CD Pipeline / Integration Tests (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Failing after 1531h39m39s

This commit is contained in:
2026-07-14 20:19:01 +08:00
parent 4805e961f0
commit acffa364b3
+7 -7
View File
@@ -160,20 +160,20 @@ def main() -> int:
try:
with urllib.request.urlopen(req, timeout=10) as resp:
resp_body = resp.read().decode("utf-8")
print(f"通知已发送 ({mode})")
# 飞书返回code=0表示成功
try:
result = json.loads(resp_body)
if result.get("code", 0) != 0:
print(f"飞书返回错误: {result.get('msg', resp_body)}", file=sys.stderr)
return 1
print(f"通知发送告警: 飞书返回错误 - {result.get('msg', resp_body)}", file=sys.stderr)
print(f"通知已发送 ({mode}) - 飞书返回非0,但不阻断CI流程")
else:
print(f"通知已发送 ({mode})")
except json.JSONDecodeError:
pass
print(f"通知已发送 ({mode})")
except Exception as e:
print(f"通知发送失败: {e}", file=sys.stderr)
# 通知失败不阻断CI主流程,仅打印告警
return 0
print(f"通知发送告警: {e}", file=sys.stderr)
# 通知无论成功失败都不阻断CI主流程,统一返回0
return 0