From 4eb17ece4ff531194362e05a9693b312a4a4f99d Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Fri, 18 Sep 2026 18:50:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8cc4b3f..88d2dda 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,12 +1,15 @@ -def sendProductionWeComNotification(String status, String color, String detail) { +def sendProductionWeComNotification(String title, String status, String color, String detail) { withCredentials([string(credentialsId: 'wecom-prod-webhook', variable: 'WECOM_WEBHOOK')]) { - String sourceVersion = env.SOURCE_TAG ?: env.GIT_COMMIT ?: '—' - String content = """## 生产部署通知 -> 项目:${env.JOB_NAME} + String sourceVersion = env.SOURCE_TAG ?: env.GIT_COMMIT ?: '未解析' + String duration = currentBuild.durationString?.replace(' and counting', '') ?: '—' + String content = """## ${title} +> 应用:客户工作台 +> Job:${env.JOB_NAME} > 构建:[#${env.BUILD_NUMBER}](${env.BUILD_URL}) > 提交:${sourceVersion} > 状态:${status} -> 详情:${detail} +${detail} +> 耗时:${duration} > 时间:${new Date().format('yyyy-MM-dd HH:mm:ss', TimeZone.getTimeZone('Asia/Shanghai'))} """ String payloadFile = 'wecom-production-notification.json' @@ -123,13 +126,6 @@ pipeline { } } - stage('确认部署生产前端') { - when { expression { env.IS_PRODUCTION == 'true' } } - steps { - input message: "确认将 main 提交 ${env.SOURCE_TAG} 部署到 app.buggoglobal.com?", ok: '确认部署' - } - } - stage('部署生产前端') { when { expression { env.IS_PRODUCTION == 'true' } } steps { @@ -199,7 +195,12 @@ pipeline { script { if (env.JOB_BASE_NAME?.endsWith('-prod')) { try { - sendProductionWeComNotification('部署成功', 'info', 'Client 生产前端已完成发布和部署检查') + sendProductionWeComNotification( + '✅ 生产部署成功', + '成功', + 'info', + '> 结果:Client 生产前端已完成发布和部署流程' + ) } catch (Exception error) { echo "企业微信通知失败,不影响原构建结果:${error.message}" } @@ -219,7 +220,12 @@ pipeline { script { if (env.JOB_BASE_NAME?.endsWith('-prod')) { try { - sendProductionWeComNotification('部署失败', 'warning', '请打开 Jenkins 构建日志查看失败阶段') + sendProductionWeComNotification( + '❌ 生产发布失败', + '失败', + 'warning', + '> 说明:请打开 Jenkins 构建日志查看失败阶段' + ) } catch (Exception error) { echo "企业微信通知失败,不影响原构建结果:${error.message}" } @@ -230,7 +236,12 @@ pipeline { script { if (env.JOB_BASE_NAME?.endsWith('-prod')) { try { - sendProductionWeComNotification('部署已取消', 'comment', '生产部署流程被人工取消或中止') + sendProductionWeComNotification( + '⏹ 生产部署已取消', + '已取消', + 'comment', + '> 说明:生产部署流程被人工取消或中止' + ) } catch (Exception error) { echo "企业微信通知失败,不影响原构建结果:${error.message}" }