Package buildbot :: Package status :: Module mail :: Class MailNotifier
[hide private]
[frames] | no frames]

Class MailNotifier

source code

                     base.StatusReceiver --+    
                                           |    
 twisted.application.service.Service --+   |    
                                       |   |    
twisted.application.service.MultiService --+    
                                           |    
                    util.ComparableMixin --+    
                                           |    
             base.StatusReceiverMultiService --+
                                               |
                                              MailNotifier

This is a status notifier which sends email to a list of recipients upon the completion of each build. It can be configured to only send out mail for certain builds, and only send messages when the build fails, or when it transitions from success to failure. It can also be configured to include various build logs in each message.

By default, the message will be sent to the Interested Users list, which includes all developers who made changes in the build. You can add additional recipients with the extraRecipients argument.

To get a simple one-message-per-build (say, for a mailing list), use sendToInterestedUsers=False, extraRecipients=['listaddr@example.org']

Each MailNotifier sends mail to a single set of recipients. To send different kinds of mail to different recipients, use multiple MailNotifiers.

Instance Methods [hide private]
 
__init__(self, fromaddr, mode="all", categories=None, builders=None, addLogs=False, relayhost="localhost", subject="buildbot %(result)s in %(projectName)s on %(builder)s", lookup=None, extraRecipients=[], sendToInterestedUsers=True, customMesg=message, extraHeaders=None)
@type fromaddr: string @param fromaddr: the email address to be used in the 'From' header.
source code
 
setServiceParent(self, parent) source code
 
setup(self) source code
 
disownServiceParent(self) source code
 
builderAdded(self, name, builder) source code
 
builderRemoved(self, name) source code
 
builderChangedState(self, name, state) source code
 
buildStarted(self, name, build) source code
 
buildFinished(self, name, build, results) source code
 
buildMessage(self, name, build, results) source code
 
_shouldAttachLog(self, logname) source code
 
_gotRecipients(self, res, rlist, m) source code
 
sendMessage(self, m, recipients) source code

Inherited from base.StatusReceiver: __providedBy__, buildETAUpdate, buildsetSubmitted, logChunk, logFinished, logStarted, requestCancelled, requestSubmitted, stepETAUpdate, stepFinished, stepStarted, stepText2Changed, stepTextChanged

Inherited from twisted.application.service.MultiService: __iter__, addService, getServiceNamed, privilegedStartService, removeService, startService, stopService

Inherited from twisted.application.service.Service: __getstate__, setName

Inherited from util.ComparableMixin: __cmp__, __hash__

Class Variables [hide private]
  compare_attrs = ["extraRecipients", "lookup", "fromaddr", "mod...

Inherited from base.StatusReceiverMultiService: __implemented__, __provides__

Inherited from twisted.application.service.Service: name, parent, running

Method Details [hide private]

__init__(self, fromaddr, mode="all", categories=None, builders=None, addLogs=False, relayhost="localhost", subject="buildbot %(result)s in %(projectName)s on %(builder)s", lookup=None, extraRecipients=[], sendToInterestedUsers=True, customMesg=message, extraHeaders=None)
(Constructor)

source code 

@type  fromaddr: string
@param fromaddr: the email address to be used in the 'From' header.
@type  sendToInterestedUsers: boolean
@param sendToInterestedUsers: if True (the default), send mail to all 
                              of the Interested Users. If False, only
                              send mail to the extraRecipients list.

@type  extraRecipients: tuple of string
@param extraRecipients: a list of email addresses to which messages
                        should be sent (in addition to the
                        InterestedUsers list, which includes any
                        developers who made Changes that went into this
                        build). It is a good idea to create a small
                        mailing list and deliver to that, then let
                        subscribers come and go as they please.

@type  subject: string
@param subject: a string to be used as the subject line of the message.
                %(builder)s will be replaced with the name of the
                builder which provoked the message.

@type  mode: string (defaults to all)
@param mode: one of:
             - 'all': send mail about all builds, passing and failing
             - 'failing': only send mail about builds which fail
             - 'passing': only send mail about builds which succeed
             - 'problem': only send mail about a build which failed
             when the previous build passed
             - 'change': only send mail about builds who change status

@type  builders: list of strings
@param builders: a list of builder names for which mail should be
                 sent. Defaults to None (send mail for all builds).
                 Use either builders or categories, but not both.

@type  categories: list of strings
@param categories: a list of category names to serve status
                   information for. Defaults to None (all
                   categories). Use either builders or categories,
                   but not both.

@type  addLogs: boolean.
@param addLogs: if True, include all build logs as attachments to the
                messages.  These can be quite large. This can also be
                set to a list of log names, to send a subset of the
                logs. Defaults to False.

@type  relayhost: string
@param relayhost: the host to which the outbound SMTP connection
                  should be made. Defaults to 'localhost'

@type  lookup:    implementor of {IEmailLookup}
@param lookup:    object which provides IEmailLookup, which is
                  responsible for mapping User names (which come from
                  the VC system) into valid email addresses. If not
                  provided, the notifier will only be able to send mail
                  to the addresses in the extraRecipients list. Most of
                  the time you can use a simple Domain instance. As a
                  shortcut, you can pass as string: this will be
                  treated as if you had provided Domain(str). For
                  example, lookup='twistedmatrix.com' will allow mail
                  to be sent to all developers whose SVN usernames
                  match their twistedmatrix.com account names.
                  
@type  customMesg: func
@param customMesg: A function that returns a tuple containing the text of
                   a custom message and its type. This function takes
                   the dict attrs which has the following values:

                   builderName - (str) Name of the builder that generated this event.

                   projectName - (str) Name of the project.
                   
                   mode - (str) Mode set in MailNotifier. (failing, passing, problem, change).

                   result - (str) Builder result as a string. 'success', 'warnings',
                            'failure', 'skipped', or 'exception'
       
                   buildURL - (str) URL to build page.

                   buildbotURL - (str) URL to buildbot main page.

                   buildText - (str) Build text from build.getText().

                   buildProperties - (Properties instance) Mapping of
                                     property names to values

                   slavename - (str) Slavename.

                   reason - (str) Build reason from build.getReason().

                   responsibleUsers - (List of str) List of responsible users.

                   branch - (str) Name of branch used. If no SourceStamp exists branch
                            is an empty string.
       
                   revision - (str) Name of revision used. If no SourceStamp exists revision
                              is an empty string.
         
                   patch - (str) Name of patch used. If no SourceStamp exists patch
                           is an empty string.

                   changes - (list of objs) List of change objects from SourceStamp. A change
                             object has the following useful information:
        
                             who - who made this change
                             revision - what VC revision is this change
                             branch - on what branch did this change occur
                             when - when did this change occur
                             files - what files were affected in this change
                             comments - comments reguarding the change.

                             The functions asText and asHTML return a list of strings with
                             the above information formatted. 

                   logs - (List of Tuples) List of tuples that contain the log name, log url,
                          and log contents as a list of strings.
@type  extraHeaders: dict
@param extraHeaders: A dict of extra headers to add to the mail. It's
                     best to avoid putting 'To', 'From', 'Date',
                     'Subject', or 'CC' in here. Both the names and
                     values may be WithProperties instances.

Overrides: twisted.application.service.MultiService.__init__

setServiceParent(self, parent)

source code 
Parameters:
Overrides: twisted.application.service.Service.setServiceParent

disownServiceParent(self)

source code 
Overrides: twisted.application.service.Service.disownServiceParent

builderAdded(self, name, builder)

source code 
Overrides: base.StatusReceiver.builderAdded

builderRemoved(self, name)

source code 
Overrides: base.StatusReceiver.builderRemoved

builderChangedState(self, name, state)

source code 
Overrides: base.StatusReceiver.builderChangedState

buildStarted(self, name, build)

source code 
Overrides: base.StatusReceiver.buildStarted

buildFinished(self, name, build, results)

source code 
Overrides: base.StatusReceiver.buildFinished

Class Variable Details [hide private]

compare_attrs

Value:
["extraRecipients", "lookup", "fromaddr", "mode", "categories", "build\
ers", "addLogs", "relayhost", "subject", "sendToInterestedUsers", "cus\
tomMesg", "extraHeaders"]