From e2804d974890b44a3f5aa6ca4bb2d77f976a1abe Mon Sep 17 00:00:00 2001 From: Shihyu Ho Date: Mon, 20 Jul 2026 17:48:50 +0800 Subject: [PATCH] fix(ci): notify on jakarta build failures instead of dead main guard The failure notification was gated on BRANCH_NAME == 'main', which is never true on the active jakarta line, so build failures never alerted anyone. Gate on branch-api's BRANCH_IS_PRIMARY flag so the guard survives a default branch rename, with a literal jakarta fallback for non-multibranch jobs where that variable is absent. Co-authored-by: Claude Opus 4.8 --- Jenkinsfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 87b766a..538bd25 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -154,7 +154,10 @@ spec: } failure { script { - if (env.BRANCH_NAME == 'main' + // BRANCH_IS_PRIMARY 由 multibranch 的 branch-api 在 SCM 預設分支上設為 'true', + // 不必隨預設分支改名而改這裡; 非 multibranch job 不會有這個變數, 故 fallback 比對分支名 + def isPrimaryBranch = env.BRANCH_IS_PRIMARY == 'true' || env.BRANCH_NAME == 'jakarta' + if (isPrimaryBranch // 若短時間太密集的 push, 之前的 job 會被 jenkins 中斷,這樣就可能會就連第一步都還沒執行的狀況,但也算是失敗 // 然而取得 git 資訊就在第一步,所以至少要第一步都有執行完才發佈 slack 吧 && env.LAST_COMMIT_AUTHOR_NAME && env.LAST_COMMIT_AUTHOR_EMAIL && env.LAST_COMMIT_TIME) {