luhaowen 3 weeks ago
parent
commit
6774d1199b

+ 2 - 1
src/com/example/FeishuNotifier.groovy

@@ -13,7 +13,7 @@ class FeishuNotifier implements Serializable {
 
 
     void send(String status, String jobName, String buildNumber, String buildUrl,
     void send(String status, String jobName, String buildNumber, String buildUrl,
               String duration, String branch, String commitMsg, String author,
               String duration, String branch, String commitMsg, String author,
-              String commitTime) {
+              String commitTime,  String builder) {
 
 
         // 1. 决定左侧条颜色 + 标题
         // 1. 决定左侧条颜色 + 标题
         def color = (status == 'START')  ? 'blue' :
         def color = (status == 'START')  ? 'blue' :
@@ -47,6 +47,7 @@ class FeishuNotifier implements Serializable {
 **提交信息**: ${commitMsg}  
 **提交信息**: ${commitMsg}  
 **作者**: ${author}  
 **作者**: ${author}  
 **提交时间**: ${commitTime}
 **提交时间**: ${commitTime}
+**构建人**: ${builder}
 """.stripIndent()
 """.stripIndent()
                         ]
                         ]
                     ],
                     ],

+ 0 - 1
vars/PrintMes.groovy

@@ -1,7 +1,6 @@
 // var/PrintMes.groovy 打印彩色字体方法
 // var/PrintMes.groovy 打印彩色字体方法
 def call(String value, String color) {
 def call(String value, String color) {
     def colors = [
     def colors = [
-        // 1 高亮 + 前景色,无背景(默认黑底就够用)
         'red'    : "\033[1;31m● ${value}\033[0m",
         'red'    : "\033[1;31m● ${value}\033[0m",
         'green'  : "\033[1;32m✔ ${value}\033[0m",
         'green'  : "\033[1;32m✔ ${value}\033[0m",
         'purple' : "\033[1;35m◆ ${value}\033[0m",
         'purple' : "\033[1;35m◆ ${value}\033[0m",

+ 2 - 1
vars/feishuNotify.groovy

@@ -10,6 +10,7 @@ def call(String webhook, String status, String branch = null) {
         info.branch,
         info.branch,
         info.commitMsg,
         info.commitMsg,
         info.author,
         info.author,
-        info.commitTime
+        info.commitTime,
+        info.builder
     )
     )
 }
 }

+ 2 - 1
vars/feishuStart.groovy

@@ -10,6 +10,7 @@ def call(String webhook, String branch = null) {
         info.branch,
         info.branch,
         info.commitMsg,
         info.commitMsg,
         info.author,
         info.author,
-        info.commitTime
+        info.commitTime,
+        info.builder
     )
     )
 }
 }

+ 4 - 2
vars/gatherInfo.groovy

@@ -4,7 +4,8 @@ def call(String branchOverride = null) {
     def commitMsg  = sh(returnStdout: true, script: 'git log -1 --pretty=%B').trim()
     def commitMsg  = sh(returnStdout: true, script: 'git log -1 --pretty=%B').trim()
     def author     = sh(returnStdout: true, script: 'git log -1 --pretty=%an').trim()
     def author     = sh(returnStdout: true, script: 'git log -1 --pretty=%an').trim()
     def commitTime = sh(returnStdout: true, script: 'git log -1 --pretty=%ci').trim()
     def commitTime = sh(returnStdout: true, script: 'git log -1 --pretty=%ci').trim()
-
+    def causes = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')
+    def builder = causes.isEmpty() ? 'auto' : causes[0].userId 
     
     
     def branch = branchOverride ?: env.GIT_BRANCH ?: env.BRANCH_NAME ?: 'unknown'
     def branch = branchOverride ?: env.GIT_BRANCH ?: env.BRANCH_NAME ?: 'unknown'
 
 
@@ -16,6 +17,7 @@ def call(String branchOverride = null) {
         author   : author,
         author   : author,
         commitTime: commitTime,
         commitTime: commitTime,
         branch   : branch,
         branch   : branch,
-        buildUrl : buildUrl
+        buildUrl : buildUrl,
+        builder  : builder 
     ]
     ]
 }
 }