| 
					
				 | 
			
			
				@@ -1,42 +0,0 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-#!/usr/bin/env groovy 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def call(String phase) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // ===== 日志:确认加载的是新代码 ===== 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    println "[feishu-card] onBuildEvent phase=${phase} , loaded from ${getClass().protectionDomain.codeSource.location}" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // ===================================== 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // 1. 先把凭据解析成真正的 URL 字符串 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    String webhook = credentials('feishu-webhook') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    println "[feishu-card] resolved webhook=${webhook}" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // 2. 取环境变量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    String jobName  = env.JOB_NAME 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    String buildNum = env.BUILD_NUMBER 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    String branch   = env.GIT_BRANCH ?: 'unknown' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    String result   = currentBuild.currentResult ?: 'UNKNOWN' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    String buildUrl = env.BUILD_URL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    String duration = phase == 'end' ? "${currentBuild.durationString}" : '-' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    String headerColor = phase == 'start' ? 'blue' : (result == 'SUCCESS' ? 'green' : 'red') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    def card = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        header: [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            title: [tag: "plain_text", content: "Jenkins ${phase == 'start' ? '开始' : '结束'}通知"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            template: headerColor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        elements: [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                tag: "div", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                text: [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    tag: "lark_md", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    content: "**项目:** ${jobName}\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                             "**分支:** ${branch}\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                             "**构建:** #${buildNum}\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                             "**结果:** ${result}\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                             "**耗时:** ${duration}\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                             "**链接:** [查看详情](${buildUrl})" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // 3. 发送 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    feishu.send(webhook, card) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 |