如何在Jenkins管道

时间:2017-09-18 05:22:59

标签: jenkins jenkins-pipeline

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

这是我写的代码。

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

1 个答案:

答案 0 :(得分:0)

正确的结构是:

emailext (
  subject: yoursubject,
  body: yourbody,
  recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)

您的代码可以类似于:

emailext (
  emailtext attachLog: true,
  compressLog: true,
  subject: 'Test results failure',
  body: 'Build failure',
  recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)

欲了解更多信息: Sending notifications pipeline