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

Add pre-send step to email-ext that can modify the mail message object

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      When the Email-Ext plugin is used in conjunction with the Claim plugin there is no way to configure a project's email options to only send to the one who has claimed it. This results in every person on a team receiving emails for a build they did not break, turning Jenkins emails into something annoying instead of something useful. For someone who knew the code this would be a pretty easy feature to add. And while this would be a good feature, I think a more elaborate solution that would allow Email-ext plugin users to access/modify all parts of the email message (including who the message is being sent to) would be more useful in the long run. Giving users access to all parts of the email message and the option to run a Groovy script after the email has been built, but before the email has been sent would satisfy this feature request and would make the Email-Ext plugin much more versatile.

        Attachments

          Issue Links

            Activity

            terrylwesterhold terryl westerhold created issue -
            terrylwesterhold terryl westerhold made changes -
            Field Original Value New Value
            Description When the Email-Ext plugin is used in conjunction with the Claim plugin there is no way to configure a project's email options to only send to culprits when build is not claimed. For someone who knew the code this would be a pretty easy feature to add. And while this would be a good feature, I think a more elaborate solution that would allow Email-ext plugin users to access/modify all parts of the email message (including who the message is being sent to) would be more useful in the long run. Giving users access to all parts of the email message and the option to run a Groovy script after the email has been built, but before the email has been sent would satisfy this feature request and would make the Email-Ext plugin much more versatile. When the Email-Ext plugin is used in conjunction with the Claim plugin there is no way to configure a project's email options to only send to culprits when build is not claimed. This results in every person on a team receiving emails for a build they did not break, turning Jenkins emails into something annoying instead of something useful. For someone who knew the code this would be a pretty easy feature to add. And while this would be a good feature, I think a more elaborate solution that would allow Email-ext plugin users to access/modify all parts of the email message (including who the message is being sent to) would be more useful in the long run. Giving users access to all parts of the email message and the option to run a Groovy script after the email has been built, but before the email has been sent would satisfy this feature request and would make the Email-Ext plugin much more versatile.
            terrylwesterhold terryl westerhold made changes -
            Description When the Email-Ext plugin is used in conjunction with the Claim plugin there is no way to configure a project's email options to only send to culprits when build is not claimed. This results in every person on a team receiving emails for a build they did not break, turning Jenkins emails into something annoying instead of something useful. For someone who knew the code this would be a pretty easy feature to add. And while this would be a good feature, I think a more elaborate solution that would allow Email-ext plugin users to access/modify all parts of the email message (including who the message is being sent to) would be more useful in the long run. Giving users access to all parts of the email message and the option to run a Groovy script after the email has been built, but before the email has been sent would satisfy this feature request and would make the Email-Ext plugin much more versatile. When the Email-Ext plugin is used in conjunction with the Claim plugin there is no way to configure a project's email options to only send to the one who has claimed it. This results in every person on a team receiving emails for a build they did not break, turning Jenkins emails into something annoying instead of something useful. For someone who knew the code this would be a pretty easy feature to add. And while this would be a good feature, I think a more elaborate solution that would allow Email-ext plugin users to access/modify all parts of the email message (including who the message is being sent to) would be more useful in the long run. Giving users access to all parts of the email message and the option to run a Groovy script after the email has been built, but before the email has been sent would satisfy this feature request and would make the Email-Ext plugin much more versatile.
            Hide
            slide_o_mix Alex Earl added a comment -

            Are you saying have a pre-send "trigger" that is passed in a Message object that can be modified before the actual sending?

            Show
            slide_o_mix Alex Earl added a comment - Are you saying have a pre-send "trigger" that is passed in a Message object that can be modified before the actual sending?
            slide_o_mix Alex Earl made changes -
            Assignee Slide-O-Mix [ slide_o_mix ]
            Hide
            terrylwesterhold terryl westerhold added a comment - - edited

            I think you hit the keyword... "pre-send". Right before the message is sent allow users to run a Groovy script that can modify the message. And just to be clear when I say "message" I mean the Java MimeMessage which contains recipient addresses, sender address, subject, body, etc.

            Show
            terrylwesterhold terryl westerhold added a comment - - edited I think you hit the keyword... "pre-send". Right before the message is sent allow users to run a Groovy script that can modify the message. And just to be clear when I say "message" I mean the Java MimeMessage which contains recipient addresses, sender address, subject, body, etc.
            slide_o_mix Alex Earl made changes -
            Summary Build failure emails are continually sent to all culprits even if one culprit has already claimed the build Add pre-send step to email-ext that can modify the mail message object
            slide_o_mix Alex Earl made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            Hide
            slide_o_mix Alex Earl added a comment -

            Would you want this only at the project level?

            Show
            slide_o_mix Alex Earl added a comment - Would you want this only at the project level?
            Hide
            terrylwesterhold terryl westerhold added a comment -

            Yes, that is what I was thinking. I am curious to know how you are thinking you will approach this issue though. Having a feature that specifically addressed the claim issue would be great, but I really think the "more elaborate solution" I mentioned in my initial post would be much more beneficial. Giving the option to run a "pre-send" script after the message was fully built would give me the ability to fix this issue, and the potential to do many other things with the MimeMessage before it was sent.

            Show
            terrylwesterhold terryl westerhold added a comment - Yes, that is what I was thinking. I am curious to know how you are thinking you will approach this issue though. Having a feature that specifically addressed the claim issue would be great, but I really think the "more elaborate solution" I mentioned in my initial post would be much more beneficial. Giving the option to run a "pre-send" script after the message was fully built would give me the ability to fix this issue, and the potential to do many other things with the MimeMessage before it was sent.
            Hide
            slide_o_mix Alex Earl added a comment -

            I am planning on adding the groovy feature, I was just wondering where you might want to configure it. If only at the project level (not at the global level and not at the trigger level) it makes it a bit easier

            Show
            slide_o_mix Alex Earl added a comment - I am planning on adding the groovy feature, I was just wondering where you might want to configure it. If only at the project level (not at the global level and not at the trigger level) it makes it a bit easier
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Alex Earl
            Path:
            src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java
            src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java
            src/main/resources/hudson/plugins/emailext/ExtendedEmailPublisher/config.jelly
            src/main/webapp/help/projectConfig/presendScript.html
            src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java
            http://jenkins-ci.org/commit/email-ext-plugin/5fa24b49277c865e63148b40d109d3df7c1a5db0
            Log:
            Fix JENKINS-12421

            Implement pre-send script that allows modifying or cancelling the
            sending of the email.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java src/main/resources/hudson/plugins/emailext/ExtendedEmailPublisher/config.jelly src/main/webapp/help/projectConfig/presendScript.html src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java http://jenkins-ci.org/commit/email-ext-plugin/5fa24b49277c865e63148b40d109d3df7c1a5db0 Log: Fix JENKINS-12421 Implement pre-send script that allows modifying or cancelling the sending of the email.
            Hide
            slide_o_mix Alex Earl added a comment -

            Implemented an area in the project config for specifying a pre-send script which can modify the email message and even cancel sending the email if desired.

            Show
            slide_o_mix Alex Earl added a comment - Implemented an area in the project config for specifying a pre-send script which can modify the email message and even cancel sending the email if desired.
            slide_o_mix Alex Earl made changes -
            Status In Progress [ 3 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            mabahj Markus made changes -
            Link This issue is related to JENKINS-11638 [ JENKINS-11638 ]
            mabahj Markus made changes -
            Link This issue is related to JENKINS-16861 [ JENKINS-16861 ]
            Hide
            mabahj Markus added a comment -

            terryl westerhold, I'm trying to achieve the same goal (JENKINS-16861) but I'm struggling with the script. Do you have something you could share?

            Show
            mabahj Markus added a comment - terryl westerhold , I'm trying to achieve the same goal ( JENKINS-16861 ) but I'm struggling with the script. Do you have something you could share?
            Hide
            cnogradi Chris Nogradi added a comment -

            Looks like you mostly had it in the comments for Jenkins-16861. Here is what we use:

            build.actions.each { action ->
            if(action.class.name == "hudson.plugins.claim.ClaimBuildAction" && action.isClaimed())

            { logger.println(action.getClaimedBy()); hudson.model.User user = hudson.model.User.get(action.getClaimedBy()); address = user.getProperty(hudson.tasks.Mailer.UserProperty).getAddress() ; logger.println("Sending to " + address ); msg.setRecipients(javax.mail.Message.RecipientType.TO, address ); }

            }

            Note that we use the LDAP plugin to talk to ActiveDirectory.

            Show
            cnogradi Chris Nogradi added a comment - Looks like you mostly had it in the comments for Jenkins-16861. Here is what we use: build.actions.each { action -> if(action.class.name == "hudson.plugins.claim.ClaimBuildAction" && action.isClaimed()) { logger.println(action.getClaimedBy()); hudson.model.User user = hudson.model.User.get(action.getClaimedBy()); address = user.getProperty(hudson.tasks.Mailer.UserProperty).getAddress() ; logger.println("Sending to " + address ); msg.setRecipients(javax.mail.Message.RecipientType.TO, address ); } } Note that we use the LDAP plugin to talk to ActiveDirectory.
            Hide
            cnogradi Chris Nogradi added a comment -

            Oh and I suppose I should mention that we occasionally receive emails from Jenkins with the an email title specifying a project which is different from the body of the email so I think there is a bug in this code that is either caused by not locking a shared resource or a cache value is not flushed properly.

            Show
            cnogradi Chris Nogradi added a comment - Oh and I suppose I should mention that we occasionally receive emails from Jenkins with the an email title specifying a project which is different from the body of the email so I think there is a bug in this code that is either caused by not locking a shared resource or a cache value is not flushed properly.
            Hide
            slide_o_mix Alex Earl added a comment -

            Are you on the latest version of email-ext? I made some mods that should resolve this.

            Show
            slide_o_mix Alex Earl added a comment - Are you on the latest version of email-ext? I made some mods that should resolve this.
            Hide
            cnogradi Chris Nogradi added a comment -

            Ah - yes we are - I'll keep an eye out and report if we observe it again.

            Show
            cnogradi Chris Nogradi added a comment - Ah - yes we are - I'll keep an eye out and report if we observe it again.
            Hide
            slide_o_mix Alex Earl added a comment -

            There is already a jira filed by Xavier Nodet.

            Show
            slide_o_mix Alex Earl added a comment - There is already a jira filed by Xavier Nodet.
            Hide
            mabahj Markus added a comment -

            Thank you very much, Chris. Your script works perfectly!

            Show
            mabahj Markus added a comment - Thank you very much, Chris. Your script works perfectly!
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 142787 ] JNJira + In-Review [ 190273 ]

              People

              • Assignee:
                slide_o_mix Alex Earl
                Reporter:
                terrylwesterhold terryl westerhold
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: