ソースを参照

Initial commit2

luhaowen 1 週間 前
コミット
04d419af4a
2 ファイル変更6 行追加18 行削除
  1. 3 11
      vars/feishu.groovy
  2. 3 7
      vars/onBuildEvent.groovy

+ 3 - 11
vars/feishu.groovy

@@ -1,19 +1,11 @@
 #!/usr/bin/env groovy
 import groovy.json.JsonOutput
-import org.feishu.SignUtil
 
-def send(String webhook, String secret, Map card) {
-    Long ts = System.currentTimeMillis() / 1000
-    String sign = SignUtil.genSign(secret, ts)
-    def body = [
-        timestamp: ts,
-        sign     : sign,
-        msg_type : "interactive",
-        card     : card
-    ]
+def send(String webhook, Map card) {
+    // 不带签名,直接发
     httpRequest(
         httpMode: 'POST',
-        requestBody: JsonOutput.toJson(body),
+        requestBody: JsonOutput.toJson([msg_type: 'interactive', card: card]),
         contentType: 'APPLICATION_JSON',
         url: webhook,
         consoleLogResponseBody: true,

+ 3 - 7
vars/onBuildEvent.groovy

@@ -41,11 +41,7 @@ def call(String phase) {
         ]
     ]
 
-    // 从 Jenkins 凭据里取机器人配置,避免硬编码
-    def robot = [
-        webhook: credentials('feishu-webhook'),
-        secret : credentials('feishu-secret')
-    ]
-
-    feishu.send(robot.webhook, robot.secret, card)
+    // 只读取 webhook 凭据,不处理 secret
+    String webhook = credentials('feishu-webhook')
+    feishu.send(webhook, card)
 }