钉钉通知调整 Stable和Prod
This commit is contained in:
parent
36def7f0c9
commit
3b9814d966
@ -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
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user