luhaowen 1 هفته پیش
والد
کامیت
cf14a707a9
2فایلهای تغییر یافته به همراه14 افزوده شده و 10 حذف شده
  1. 4 2
      src/com/example/FeishuNotifier.groovy
  2. 10 8
      vars/feishuNotify.groovy

+ 4 - 2
src/com/example/FeishuNotifier.groovy

@@ -12,7 +12,8 @@ class FeishuNotifier implements Serializable {
     }
 
     void send(String status, String jobName, String buildNumber, String buildUrl,
-              String duration, String branch, String commitMsg, String author) {
+              String duration, String branch, String commitMsg, String author,
+              String commitTime) {              // 新增参数
         def payload = [
             msg_type: 'text',
             content: [
@@ -24,13 +25,14 @@ class FeishuNotifier implements Serializable {
                 分支: ${branch}
                 提交: ${commitMsg}
                 作者: ${author}
+                提交时间: ${commitTime}        // 新增
                 查看详情: ${buildUrl}
                 """.stripIndent()
             ]
         ]
 
         def jsonBody = JsonOutput.toJson(payload)
-        println ">>> Feishu JSON: ${jsonBody}"
+        script.println ">>> Feishu JSON: ${jsonBody}"
 
         script.httpRequest(
             url        : webhookUrl,

+ 10 - 8
vars/feishuNotify.groovy

@@ -5,16 +5,18 @@ def call(String webhookUrl, String status) {
     def duration = currentBuild.durationString.replace(' and counting', '')
     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 commitTime = sh(returnStdout: true, script: "git log -1 --pretty=%ci").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
+        status,
+        env.JOB_NAME,
+        env.BUILD_NUMBER,
+        env.BUILD_URL,
+        duration,
+        branch,
+        commitMsg,
+        author,
+        commitTime          // 新增
     )
 }