Update vars/notifyLark.groovy
This commit is contained in:
@@ -1,3 +1,34 @@
|
|||||||
|
def buildCommitDiffMarkdown() {
|
||||||
|
def changeSets = currentBuild.changeSets
|
||||||
|
|
||||||
|
if (!changeSets || changeSets.isEmpty()) {
|
||||||
|
return '_本次构建无代码变更_'
|
||||||
|
}
|
||||||
|
|
||||||
|
def commits = []
|
||||||
|
|
||||||
|
changeSets.each { cs ->
|
||||||
|
cs.items.each { item ->
|
||||||
|
def author = item.author?.fullName ?: 'unknown'
|
||||||
|
def msg = item.msg?.trim()?.replaceAll('[\\r\\n]+', ' ')
|
||||||
|
commits << "- **${msg}**(${author})"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commits.isEmpty()) {
|
||||||
|
return '_本次构建无代码变更_'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 防止消息过长(飞书卡片有长度限制)
|
||||||
|
def maxCommits = 5
|
||||||
|
if (commits.size() > maxCommits) {
|
||||||
|
commits = commits.take(maxCommits)
|
||||||
|
commits << "_……以及更多提交_"
|
||||||
|
}
|
||||||
|
|
||||||
|
return commits.join('\n')
|
||||||
|
}
|
||||||
|
|
||||||
def call(Map args = [:]) {
|
def call(Map args = [:]) {
|
||||||
|
|
||||||
// ===== 参数 =====
|
// ===== 参数 =====
|
||||||
@@ -32,7 +63,8 @@ def call(Map args = [:]) {
|
|||||||
ABORTED : "<text_tag color='neutral'>已中止</text_tag>"
|
ABORTED : "<text_tag color='neutral'>已中止</text_tag>"
|
||||||
][buildStatus] ?: "<text_tag color='neutral'>未知状态</text_tag>"
|
][buildStatus] ?: "<text_tag color='neutral'>未知状态</text_tag>"
|
||||||
|
|
||||||
def commitDiff = "[查看变更记录](${buildUrl}changes)"
|
// def commitDiff = "[查看变更记录](${buildUrl}changes)"
|
||||||
|
def commitDiff = buildCommitDiffMarkdown()
|
||||||
|
|
||||||
// ===== 凭证 =====
|
// ===== 凭证 =====
|
||||||
withCredentials([
|
withCredentials([
|
||||||
|
|||||||
Reference in New Issue
Block a user