Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-43202

sendToIndividuals fails to mail culprits in declarative pipeline

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: mailer-plugin
    • Labels:
      None
    • Environment:
      Jenkins: 2.52
      Mailer plugin: 1.20
      Git plugin: 3.1.0
    • Similar Issues:

      Description

      I have a declarative pipeline job. The Jenkinsfile has the following snippet:

       

      post {
        failure {
          step([$class: 'Mailer', recipients: 'ci@example.com', sendToIndividuals: true])
        }
      }

       

      When the build fails, the addresses in the recipients string successfully receive mail. However the culprits responsible for the broken commit do not receive an individual email. As I have set the sendToIndividuals, I expect that they would. I've been unable to find any logs that might suggest a misconfiguration.

       

      I have been able to workaround this issue with the mail-ext plugin by changing the above snippet to:

       

      post {
        failure {
          step([
            $class: 'Mailer',
            recipients: ['ci@example.com', emailextrecipients([[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']])].join(' ')
          ])
        }
      }

       

      But I had hoped that this would work without introducing another plugin.

        Attachments

          Activity

          Hide
          slide_o_mix Alex Earl added a comment -

          The issue here is that Mailer uses AbstractBuild.getCulprits to retrieve the list of culprits for the build. So, for a pipeline job (which does not inherit from AbstractBuild), you don't have that available. Email-ext does this using the following code:

           

          https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/java/hudson/plugins/emailext/plugins/recipients/CulpritsRecipientProvider.java#L58

           

          So, something like this would need to be added to Mailer.

          Show
          slide_o_mix Alex Earl added a comment - The issue here is that Mailer uses AbstractBuild.getCulprits to retrieve the list of culprits for the build. So, for a pipeline job (which does not inherit from AbstractBuild), you don't have that available. Email-ext does this using the following code:   https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/java/hudson/plugins/emailext/plugins/recipients/CulpritsRecipientProvider.java#L58   So, something like this would need to be added to Mailer.

            People

            • Assignee:
              Unassigned
              Reporter:
              jdufresne Jon Dufresne
            • Votes:
              9 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated: