如何在构建失败时在jenkins管道中自动添加邮件收件人 [英] How to automatically add mail recipients in jenkins pipeline on build failure

查看:295
本文介绍了如何在构建失败时在jenkins管道中自动添加邮件收件人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力向在Jenkins中提交代码的用户发送有关构建失败的电子邮件。我正在使用管道脚本。但我现在很震惊,因为我手动添加用户名。如何在Jenkins中自动添加收件人邮件。 

这是我写的代码。

emailtext attachLog:true,body:'',compressLog:true,recipientProviders:[[$ class:'DevelopersRecipientProvider']],主题:'测试结果'emailtext body:'Commit failure',subject :'测试失败',至:'abc@xyz.com'





我尝试过:



 emailtext attachLog:true,body:'',compressLog:true,recipientProviders:[[$ class:'DevelopersRecipientProvider']], subject:'测试结果'emailtext body:'提交失败',主题:'测试失败',到:'abc@xyz.com'

解决方案

class:'DevelopersRecipientProvider']],主题:'测试结果'emailtext body:'提交失败',主题:'测试失败',到:'abc@xyz.com'





我的尝试:



 emailtext attachLog:true,body:'',compressLog:true,recipientProviders:


class: 'DevelopersRecipientProvider'],主题:'测试结果'emailtext body:'提交失败',主题:'测试失败',到:'abc@xyz.com'


我解决了它我只是添加了以下代码!!!



 script {def recipients = emailextrecipients([

I am working on to send an email on build failure to the users who had committed the code in Jenkins. I am using pipeline script. But i am struck now as i am manually adding the username. How to automatically add recipient mail in Jenkins.

Here is the code i have written.

emailtext attachLog: true,body: '', compressLog: true, recipientProviders: [[$class: 'DevelopersRecipientProvider']], subject:'Test results' emailtext body : 'Commit failure', subject: 'Test-failure', to: 'abc@xyz.com'



What I have tried:

emailtext attachLog: true,body: '', compressLog: true, recipientProviders: [[$class: 'DevelopersRecipientProvider']], subject:'Test results' emailtext body : 'Commit failure', subject: 'Test-failure', to: 'abc@xyz.com'

解决方案

class: 'DevelopersRecipientProvider']], subject:'Test results' emailtext body : 'Commit failure', subject: 'Test-failure', to: 'abc@xyz.com'



What I have tried:

emailtext attachLog: true,body: '', compressLog: true, recipientProviders:


class: 'DevelopersRecipientProvider']], subject:'Test results' emailtext body : 'Commit failure', subject: 'Test-failure', to: 'abc@xyz.com'


I got it solved i just added the below code!!!

           script{ def recipients = emailextrecipients([


这篇关于如何在构建失败时在jenkins管道中自动添加邮件收件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆