Bladeren bron

Initial commit11

luhaowen 1 week geleden
bovenliggende
commit
e8e61b89f3
1 gewijzigde bestanden met toevoegingen van 21 en 23 verwijderingen
  1. 21 23
      src/com/example/FeishuNotifier.groovy

+ 21 - 23
src/com/example/FeishuNotifier.groovy

@@ -14,37 +14,35 @@ class FeishuNotifier implements Serializable {
 
     void send(String status, String jobName, String buildNumber, String buildUrl, String duration) {
         def colorMap = [
-            'SUCCESS': 'green',
-            'FAILURE': 'red',
+            'SUCCESS' : 'green',
+            'FAILURE' : 'red',
             'UNSTABLE': 'yellow',
-            'ABORTED': 'gray'
+            'ABORTED' : 'gray'
         ]
-        def title = "Jenkins构建通知"
-        def text = """
-        🚀 **构建状态**: ${status}\n
-        📦 **任务名称**: ${jobName}\n
-        🔢 **构建编号**: #${buildNumber}\n
-        ⏱️ **持续时间**: ${duration}\n
-        🔗 [点击查看详情](${buildUrl})
-        """.stripIndent()
-
         def payload = [
-            msg_type: "text",
+            msg_type: 'post',
             content: [
-                text: """
-                构建状态: ${status}
-                任务名称: ${jobName}
-                构建编号: #${buildNumber}
-                持续时间: ${duration}
-                查看详情: ${buildUrl}
-                """.stripIndent()
-
+                post: [
+                    zh_cn: [
+                        title: "Jenkins 构建通知",
+                        content: [[
+                            tag : 'text',
+                            text: """
+                            构建状态 : ${status}
+                            任务名称 : ${jobName}
+                            构建编号 : #${buildNumber}
+                            持续时间 : ${duration}
+                            查看详情 : ${buildUrl}
+                            """.stripIndent()
+                        ]]
+                    ]
+                ]
             ]
         ]
 
         script.httpRequest(
-            url: webhookUrl,
-            httpMode: 'POST',
+            url        : webhookUrl,
+            httpMode   : 'POST',
             requestBody: JsonOutput.toJson(payload),
             contentType: 'APPLICATION_JSON',
             consoleLogResponseBody: true