package com.example import groovy.json.JsonOutput class FeishuNotifier implements Serializable { def script String webhookUrl FeishuNotifier(script, String webhookUrl) { this.script = script this.webhookUrl = webhookUrl } void send(String status, String jobName, String buildNumber, String buildUrl, String duration, String branch, String commitMsg, String author, String commitTime) { // 新增参数 def payload = [ msg_type: 'text', content: [ text: """ 构建状态: ${status} 任务名称: ${jobName} 构建编号: #${buildNumber} 持续时间: ${duration} 分支: ${branch} 提交: ${commitMsg} 作者: ${author} 提交时间: ${commitTime} // 新增 查看详情: ${buildUrl} """.stripIndent() ] ] def jsonBody = JsonOutput.toJson(payload) script.println ">>> Feishu JSON: ${jsonBody}" script.httpRequest( url : webhookUrl, httpMode : 'POST', requestBody: jsonBody, contentType: 'APPLICATION_JSON', consoleLogResponseBody: true ) } }