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

Email-ext sends an email when it shouldn't, and problems handling $PROJECT_DEFAULT_RECIPIENTS

    Details

    • Similar Issues:

      Description

      This problem looks like it appeared in email-ext v2.15.

      We have configured a "Success" trigger" which, in the "Advanced" section, has all "Send to ..." options DE-selected. Thus if a build succeeds (and the previous build was also a success), then I don't expect any email to be sent. However, since 2.15, on success an email is sent to the global recipient list.

      A suggested workaround was removing $PROJECT_DEFAULT_RECIPIENTS from the trigger's list of recipients, so that the list was empty. This initially appeared to have worked, however when Jenkins is restarted, $PROJECT_DEFAULT_RECIPIENTS is added back to list of trigger recipients.

      I think the email-ext plugin is confused about recipient lists. There is a system-wide recipient list defined under "Manage Jenkins", then in each job which uses email-ext there is a "Global Recipient List" (which is not system-wide as the name global might suggest), and then for each separate trigger there is a "recipient" list. It is not at all clear how these interact, and what the "send to recipient list" option really means.

        Attachments

          Activity

          Hide
          dennisl Dennis Lundberg added a comment -

          We downgraded to version 2.14.1 again, but this doesn't work well either. Now we get a lot of failed e-maildeliveries from the e-mailserver claiming that $PROJECT_DEFAULT_RECIPIENTS@our.domain cannot be reached.

          That piece of configuration is in every Recipient List for every Trigger for every Job. That's a lot of places we need to reconfigure!

          Show
          dennisl Dennis Lundberg added a comment - We downgraded to version 2.14.1 again, but this doesn't work well either. Now we get a lot of failed e-maildeliveries from the e-mailserver claiming that $PROJECT_DEFAULT_RECIPIENTS@our.domain cannot be reached. That piece of configuration is in every Recipient List for every Trigger for every Job. That's a lot of places we need to reconfigure!
          Hide
          slide_o_mix Alex Earl added a comment -

          I believe I have a fix for this, I'll push to my github repo and people can build and test it out from there. If it works I'll merge with the mainline and do a release.

          Show
          slide_o_mix Alex Earl added a comment - I believe I have a fix for this, I'll push to my github repo and people can build and test it out from there. If it works I'll merge with the mainline and do a release.
          Hide
          slide_o_mix Alex Earl added a comment -

          The global default recipients feature has been removed. Please use the following script as the basis to update the triggers to remove $PROJECT_DEFAULT_RECIPIENTS

          noformat
          import hudson.model.AbstractProject
          import hudson.model.Descriptor
          import hudson.plugins.emailext.ExtendedEmailPublisher
          import hudson.plugins.emailext.plugins.EmailTrigger;
          import hudson.tasks.Publisher
          import hudson.util.DescribableList
          import jenkins.model.Jenkins

          for (AbstractProject item in Jenkins.instance.items) {
          DescribableList<Publisher, Descriptor<Publisher>> publist =
          item.getPublishersList()

          ExtendedEmailPublisher pub = publist?.get(ExtendedEmailPublisher.class)
          println(pub)

          List<EmailTrigger> triggers = pub?.getConfiguredTriggers()
          for (EmailTrigger trigger in triggers)

          { // this sets to an empty string, please // use a read/modify/set if you have // email addresses there trigger.getEmail().setRecipientList("") }

          item.save()
          }
          noformat

          Show
          slide_o_mix Alex Earl added a comment - The global default recipients feature has been removed. Please use the following script as the basis to update the triggers to remove $PROJECT_DEFAULT_RECIPIENTS noformat import hudson.model.AbstractProject import hudson.model.Descriptor import hudson.plugins.emailext.ExtendedEmailPublisher import hudson.plugins.emailext.plugins.EmailTrigger; import hudson.tasks.Publisher import hudson.util.DescribableList import jenkins.model.Jenkins for (AbstractProject item in Jenkins.instance.items) { DescribableList<Publisher, Descriptor<Publisher>> publist = item.getPublishersList() ExtendedEmailPublisher pub = publist?.get(ExtendedEmailPublisher.class) println(pub) List<EmailTrigger> triggers = pub?.getConfiguredTriggers() for (EmailTrigger trigger in triggers) { // this sets to an empty string, please // use a read/modify/set if you have // email addresses there trigger.getEmail().setRecipientList("") } item.save() } noformat
          Hide
          helenov Heleno Valle added a comment -

          This fix is already available? In which version? If not yet, any idea of when it will?

          Show
          helenov Heleno Valle added a comment - This fix is already available? In which version? If not yet, any idea of when it will?
          Hide
          slide_o_mix Alex Earl added a comment -

          Sorry, I got tied up with some major stuff at work. I need to make sure my fix actually works a bit more and then I'll merge.

          Show
          slide_o_mix Alex Earl added a comment - Sorry, I got tied up with some major stuff at work. I need to make sure my fix actually works a bit more and then I'll merge.

            People

            • Assignee:
              slide_o_mix Alex Earl
              Reporter:
              mwebber Matthew Webber
            • Votes:
              6 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: