luhaowen 1 周之前
父节点
当前提交
257be7a8a5
共有 1 个文件被更改,包括 13 次插入8 次删除
  1. 13 8
      vars/feishuNotify.groovy

+ 13 - 8
vars/feishuNotify.groovy

@@ -1,15 +1,20 @@
 #!/usr/bin/env groovy
-
 import com.example.FeishuNotifier
 
 def call(String webhookUrl, String status) {
     def duration = currentBuild.durationString.replace(' and counting', '')
-    def notifier = new FeishuNotifier(this, webhookUrl)
-    notifier.send(
-        status,
-        env.JOB_NAME,
-        env.BUILD_NUMBER,
-        env.BUILD_URL,
-        duration
+    def commitMsg  = sh(returnStdout: true, script: "git log -1 --pretty=%B").trim()
+    def author     = sh(returnStdout: true, script: "git log -1 --pretty=%an").trim()
+    def branch     = env.GIT_BRANCH ?: env.BRANCH_NAME ?: 'unknown'
+
+    new FeishuNotifier(this, webhookUrl).send(
+        status,                      // 1
+        env.JOB_NAME,                // 2
+        env.BUILD_NUMBER,            // 3
+        env.BUILD_URL,               // 4
+        duration,                    // 5
+        branch,                      // 6
+        commitMsg,                   // 7
+        author                       // 8
     )
 }