Browse Source

Merge branch 'master' of https://git.mayan31370.space/aibaidu/aisite

harryYao 2 years ago
parent
commit
29443f9844
1 changed files with 27 additions and 6 deletions
  1. 27 6
      Jenkinsfile

+ 27 - 6
Jenkinsfile

@@ -46,12 +46,33 @@ pipeline {
         }
       }
     }
-    stage('Send notify'){
-      steps{
-        script{
-          sh "curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=743fe5f4-d4cf-4906-8aa5-93353a4287da' -H 'Content-Type: application/json' -d '{\"msgtype\": \"markdown\",\"markdown\": {\"content\": \"### H5落地页\n<font color=\"info\">部署完成</font>\",\"mentioned_list\":[\"@all\"]}}'"
+    
+        stage('Send notify'){
+            steps{
+                script{
+                    def content = "### H5落地页\n<font color='info'>部署完成</font>" + getChangeString()
+                    sh "curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=743fe5f4-d4cf-4906-8aa5-93353a4287da' -H 'Content-Type: application/json' -d '{\"msgtype\": \"markdown\",\"markdown\": {\"content\": \"${content}\",\"mentioned_list\":[\"@all\"]}}'"
+                }
+            }
         }
-      }
     }
-  }
+}
+@NonCPS
+def getChangeString() {
+    MAX_MSG_LEN = 100
+    def changeString = ""
+    echo "Gathering SCM changes"
+    def changeLogSets = currentBuild.changeSets
+    for (int i = 0; i < changeLogSets.size(); i++) {
+        def entries = changeLogSets[i].items
+        for (int j = 0; j < entries.length; j++) {
+            def entry = entries[j]
+            truncated_msg = entry.msg.take(MAX_MSG_LEN)
+            changeString += " - ${truncated_msg} [${entry.author}]\n"
+        }
+    }
+    if (!changeString) {
+        changeString = " - No new changes"
+    }
+    return changeString
 }