Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add "default recipients" ($DEFAULT_RECIPIENTS) to recipientProviders in Jenkins EmailExt?

I am using Jenkins and Emailext plugin for emailing. Here is a test pipeline, which works fine:

pipeline
{
  agent any

  stages
  {
    stage ('Start')
    {
      steps
      {
        echo 'Hello'
        // error('Abort to test failure.')
      }
    }
  }

  post
  {
    success
    {
      emailext (
          subject: '$DEFAULT_SUBJECT',
          body: '$DEFAULT_CONTENT',
          recipientProviders: [ requestor(), ? ]
        )
    }

    failure
    {
      emailext (
          subject: '$DEFAULT_SUBJECT',
          body: '$DEFAULT_CONTENT',
          recipientProviders: [developers(), requestor(), culprits()]
        )
    }
  }
}

I would like to send success emails to requestor and to "default recipients" which I specified under Manage Jenkins -> Configure System -> Extended E-mail Notification.

How do I add "default recipients" ($DEFAULT_RECIPIENTS) to recipientProviders?

like image 602
Danijel Avatar asked Oct 24 '25 00:10

Danijel


1 Answers

Try like this:

success
    {
      emailext (
          subject: '$DEFAULT_SUBJECT',
          body: '$DEFAULT_CONTENT',
          to: '$DEFAULT_RECIPIENTS',
          recipientProviders: [ requestor() ]
        )
    }

recipientProviders parameter is used to add additional recipients.

This will send the email to both recipientProviders and DEFAULT_RECIPIENTS whenever job is success.

like image 83
Sourav Atta Avatar answered Oct 27 '25 03:10

Sourav Atta