钉钉通知调整 Stable和Prod

This commit is contained in:
zhang hongbo 2026-01-24 11:35:43 +08:00
parent 36def7f0c9
commit 3b9814d966
2 changed files with 112 additions and 24 deletions

View File

@ -71,18 +71,62 @@ def call(Map config)
{
always
{
dingtalk(
robot:'dingtalk_unity_1',
type:'MARKDOWN',
title:'Build Notice',
text: [
"### ${currentBuild.currentResult}",
"- Project: ${env.JOB_NAME}",
"- BuildNumber: #${env.BUILD_NUMBER}",
"- Duration: ${currentBuild.durationString}",
"- LogUrl: ${env.BUILD_URL}"
]
)
script {
//
def triggerUser = "自动触发"
def buildCause = currentBuild.getBuildCauses()
if (buildCause && buildCause.size() > 0 && buildCause[0].userName) {
triggerUser = buildCause[0].userName
}
//
def failedStage = ""
if (currentBuild.currentResult == 'FAILURE') {
def stages = currentBuild.rawBuild.getAction(org.jenkinsci.plugins.workflow.job.views.FlowGraphAction)?.getNodes()
if (stages) {
for (stage in stages) {
if (stage.getError() != null) {
failedStage = "\n- 失败阶段: ${stage.getDisplayName()}"
break
}
}
}
}
//
def changeString = ""
def changeLogSets = currentBuild.changeSets
if (changeLogSets.size() > 0) {
changeString = "\n\n提交记录:\n"
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]
changeString += "- ${entry.commitId.take(7)} ${entry.msg} - ${entry.author}\n"
}
}
} else {
changeString = "\n\n提交记录: 无变更"
}
dingtalk(
robot:'dingtalk_unity_1',
type:'MARKDOWN',
title:'构建通知',
text: [
"### ${currentBuild.currentResult}",
"\n构建信息:",
"- 项目: ${env.JOB_NAME}",
"- 构建号: #${env.BUILD_NUMBER}",
"- 分支: USA",
"- 触发者: ${triggerUser}",
"- 耗时: ${currentBuild.durationString}${failedStage}",
"\n链接:",
"- [下载链接](${env.BUILD_URL})",
changeString
]
)
}
}
}
}

View File

@ -71,18 +71,62 @@ def call(Map config)
{
always
{
dingtalk(
robot:'dingtalk_unity_1',
type:'MARKDOWN',
title:'Build Notice',
text: [
"### ${currentBuild.currentResult}",
"- Project: ${env.JOB_NAME}",
"- BuildNumber: #${env.BUILD_NUMBER}",
"- Duration: ${currentBuild.durationString}",
"- LogUrl: ${env.BUILD_URL}"
]
)
script {
//
def triggerUser = "自动触发"
def buildCause = currentBuild.getBuildCauses()
if (buildCause && buildCause.size() > 0 && buildCause[0].userName) {
triggerUser = buildCause[0].userName
}
//
def failedStage = ""
if (currentBuild.currentResult == 'FAILURE') {
def stages = currentBuild.rawBuild.getAction(org.jenkinsci.plugins.workflow.job.views.FlowGraphAction)?.getNodes()
if (stages) {
for (stage in stages) {
if (stage.getError() != null) {
failedStage = "\n- 失败阶段: ${stage.getDisplayName()}"
break
}
}
}
}
//
def changeString = ""
def changeLogSets = currentBuild.changeSets
if (changeLogSets.size() > 0) {
changeString = "\n\n提交记录:\n"
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]
changeString += "- ${entry.commitId.take(7)} ${entry.msg} - ${entry.author}\n"
}
}
} else {
changeString = "\n\n提交记录: 无变更"
}
dingtalk(
robot:'dingtalk_unity_1',
type:'MARKDOWN',
title:'构建通知',
text: [
"### ${currentBuild.currentResult}",
"\n构建信息:",
"- 项目: ${env.JOB_NAME}",
"- 构建号: #${env.BUILD_NUMBER}",
"- 分支: QA",
"- 触发者: ${triggerUser}",
"- 耗时: ${currentBuild.durationString}${failedStage}",
"\n链接:",
"- [下载链接](${env.BUILD_URL})",
changeString
]
)
}
}
}
}