Jenkins Pipeline Script:发送电子邮件通知



我想在任何工作完成时通过 Jeenkins 脚本管道发送电子邮件通知。向签入 git 的特定开发人员/组发送电子邮件。我需要有关所述脚本的帮助。

使用Email-ext 插件,使用文档对其进行配置并添加类似的代码:

pipeline {
agent any
stages {
stage('Build') {
steps {
sh "sh deploy.sh"
}
}
}
post {
always {
emailext body: 'Hello sainath kadaverugu', recipientProviders: [$class: 'DevelopersRecipientProvider'], subject: 'After build message'
}
}
}

如果您想获取上次提交者的电子邮件地址,请查看此线程

编辑:在"节点样式"中,我使用了邮件程序

def get_mail() {
node('master'){
USER_MAIL = wrap([$class: 'BuildUser']) {
return env.BUILD_USER_EMAIL
}
}
}
def USER_MAIL = get_mail()
node('master') {
stage('Checkout') {
deleteDir()
git 'git@sometest.git'
}
stage('Deploy') {
sh "sh depoly.sh"
}
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: USER_MAIL, sendToIndividuals: true])
}

相关内容

最新更新