Ver Fonte

Initial commit12

luhaowen há 1 semana atrás
pai
commit
4f611f9d61
1 ficheiros alterados com 12 adições e 15 exclusões
  1. 12 15
      src/com/example/FeishuNotifier.groovy

+ 12 - 15
src/com/example/FeishuNotifier.groovy

@@ -13,28 +13,25 @@ class FeishuNotifier implements Serializable {
 
     void send(String status, String jobName, String buildNumber, String buildUrl, String duration) {
         def payload = [
-            msg_type: 'post',
+            msg_type: 'text',
             content: [
-                post: [
-                    title: "Jenkins 构建通知",
-                    content: [   // ← 一维数组
-                        [
-                            tag : "text",
-                            text: """状态:${status}
-任务:${jobName}
-编号:#${buildNumber}
-耗时:${duration}
-链接:${buildUrl}""".stripIndent()
-                        ]
-                    ]
-                ]
+                text: """
+                构建状态: ${status}
+                任务名称: ${jobName}
+                构建编号: #${buildNumber}
+                持续时间: ${duration}
+                查看详情: ${buildUrl}
+                """.stripIndent()
             ]
         ]
 
+        def jsonBody = JsonOutput.toJson(payload)
+        println ">>> Feishu JSON: ${jsonBody}"
+
         script.httpRequest(
             url        : webhookUrl,
             httpMode   : 'POST',
-            requestBody: JsonOutput.toJson(payload),
+            requestBody: jsonBody,
             contentType: 'APPLICATION_JSON',
             consoleLogResponseBody: true
         )