Add production email notification pipeline
This commit is contained in:
@@ -16,6 +16,7 @@ pipeline {
|
||||
booleanParam(name: 'CONFIRM_RELEASE_DEPLOY_AGENT', defaultValue: false, description: '确认 release 目标已有独立 release 部署 agent;当前 Linux 开发/构建/开发部署 agent 不可冒充 release 部署机')
|
||||
string(name: 'SOURCE_BRANCH', defaultValue: 'master', description: '部署脚本来源分支')
|
||||
string(name: 'COMMIT_HASH', defaultValue: '', description: '部署脚本来源 commit;上游触发时传实际构建 commit')
|
||||
string(name: 'NOTIFICATION_EMAILS', defaultValue: '', description: '本次运行追加通知邮箱;会与 Jenkins 全局环境变量 GENARRATIVE_NOTIFICATION_EMAILS 合并发送')
|
||||
string(name: 'BUILD_VERSION', defaultValue: '', description: '待发布版本号')
|
||||
string(name: 'BUILD_JOB_NAME', defaultValue: 'Genarrative-Api-Build', description: 'API 构建流水线作业名')
|
||||
string(name: 'BUILD_NUMBER_TO_DEPLOY', defaultValue: '', description: '要复制归档产物的上游构建号')
|
||||
@@ -112,6 +113,34 @@ pipeline {
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
def notificationParameters = [
|
||||
string(name: 'SOURCE_JOB_NAME', value: env.JOB_NAME),
|
||||
string(name: 'SOURCE_BUILD_NUMBER', value: env.BUILD_NUMBER),
|
||||
string(name: 'SOURCE_BUILD_URL', value: env.BUILD_URL ?: ''),
|
||||
string(name: 'SOURCE_RESULT', value: currentBuild.currentResult ?: 'UNKNOWN'),
|
||||
string(name: 'SOURCE_BRANCH', value: params.SOURCE_BRANCH ?: ''),
|
||||
string(name: 'SOURCE_COMMIT', value: env.SOURCE_COMMIT ?: (params.COMMIT_HASH ?: '')),
|
||||
string(name: 'BUILD_VERSION', value: env.EFFECTIVE_BUILD_VERSION ?: (params.BUILD_VERSION ?: '')),
|
||||
string(name: 'DEPLOY_TARGET', value: params.DEPLOY_TARGET ?: ''),
|
||||
string(name: 'DATABASE', value: params.DATABASE ?: ''),
|
||||
string(name: 'SUMMARY', value: 'API 发布流水线结束'),
|
||||
]
|
||||
def notificationRecipients = params.NOTIFICATION_EMAILS?.trim()
|
||||
if (notificationRecipients) {
|
||||
notificationParameters.add(string(name: 'EMAIL_RECIPIENTS', value: notificationRecipients))
|
||||
}
|
||||
try {
|
||||
build job: 'Genarrative-Notify-Email',
|
||||
wait: false,
|
||||
propagate: false,
|
||||
parameters: notificationParameters
|
||||
} catch (error) {
|
||||
echo "邮件通知触发失败: ${error.message}"
|
||||
}
|
||||
}
|
||||
}
|
||||
success {
|
||||
echo "API 发布完成: version=${params.BUILD_VERSION}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user