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

Class MailNotifier

source code

                 base.StatusReceiverBase --+    
                                           |    
 twisted.application.service.Service --+   |    
                                       |   |    
twisted.application.service.MultiService --+    
                                           |    
                    util.ComparableMixin --+    
                                           |    
             base.StatusReceiverMultiService --+
                                               |
                                              MailNotifier
Known Subclasses:

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
 
__init__(self, fromaddr, mode=('failing', 'passing', 'warnings'), categories=None, builders=None, addLogs=False, relayhost='localhost', buildSetSummary=False, subject='buildbot %(result)s in %(title)s on %(builder)s', lookup=None, extraRecipients=[], sendToInterestedUsers=True, customMesg=None, messageFormatter=<function defaultMessage at 0x3e41500>, extraHeaders=None, addPatch=True, useTls=False, smtpUser=None, smtpPassword=None, smtpPort=25) source code
 
setServiceParent(self, parent) source code
 
startService(self) source code
 
stopService(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
 
isMailNeeded(self, build, results) source code
 
buildFinished(self, name, build, results) source code
 
buildsetFinished(self, bsid, result) source code
 
getCustomMesgData(self, mode, name, build, results, master_status) source code
 
patch_to_attachment(self, patch, index) source code
 
createEmail(self, msgdict, builderName, title, results, builds=None, patches=None, logs=None) source code
 
buildMessageDict(self, name, build, results) source code
 
buildMessage(self, name, builds, results) source code
 
useLookup(self, build) source code
 
useUsers(self, build) source code
 
sendmail(self, s, recipients) source code
 
sendMessage(self, m, recipients) source code
 
__provides__(...)
Special descriptor for class __provides__

Inherited from base.StatusReceiverBase: __providedBy__, buildETAUpdate, buildsetSubmitted, changeAdded, checkConfig, logChunk, logFinished, logStarted, requestCancelled, requestSubmitted, slaveConnected, slaveDisconnected, stepETAUpdate, stepFinished, stepStarted, stepText2Changed, stepTextChanged

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

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

Inherited from util.ComparableMixin: __cmp__, __hash__

Class Variables
  compare_attrs = ['extraRecipients', 'lookup', 'fromaddr', 'mod...
  possible_modes = ('change', 'failing', 'passing', 'problem', '...
  __implemented__ = <implementedBy buildbot.status.mail.MailNoti...

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

Method Details

__init__(self, fromaddr, mode=('failing', 'passing', 'warnings'), categories=None, builders=None, addLogs=False, relayhost='localhost', buildSetSummary=False, subject='buildbot %(result)s in %(title)s on %(builder)s', lookup=None, extraRecipients=[], sendToInterestedUsers=True, customMesg=None, messageFormatter=<function defaultMessage at 0x3e41500>, extraHeaders=None, addPatch=True, useTls=False, smtpUser=None, smtpPassword=None, smtpPort=25)
(Constructor)

source code 
Parameters:
  • fromaddr (string) - the email address to be used in the 'From' header.
  • sendToInterestedUsers (boolean) - if True (the default), send mail to all of the Interested Users. If False, only send mail to the extraRecipients list.
  • extraRecipients (tuple of strings) - 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. The addresses in this list are used literally (they are not processed by lookup).
  • subject (string) - 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.
  • mode (list of strings) - a list of MailNotifer.possible_modes:
    • "change": send mail about builds which change status
    • "failing": send mail about builds which fail
    • "passing": send mail about builds which succeed
    • "problem": send mail about a build which failed when the previous build passed
    • "warnings": send mail if a build contain warnings
    • "exception": send mail if a build fails due to an exception
    • "all": always send mail Defaults to ("failing", "passing", "warnings").
  • builders (list of strings) - 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.
  • categories (list of strings) - a list of category names to serve status information for. Defaults to None (all categories). Use either builders or categories, but not both.
  • addLogs (boolean) - 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.
  • addPatch (boolean) - if True, include the patch when the source stamp includes one.
  • relayhost (string) - the host to which the outbound SMTP connection should be made. Defaults to 'localhost'
  • buildSetSummary (boolean) - if True, this notifier will only send a summary email when a buildset containing any of its watched builds completes
  • lookup (implementor of {IEmailLookup}) - object which provides IEmailLookup, which is responsible for mapping User names for Interested Users (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.
  • customMesg (func) - (this function is deprecated)
  • messageFormatter (func) - function taking (mode, name, build, result, master_status) and returning a dictionary containing two required keys "body" and "type", with a third optional key, "subject". The "body" key gives a string that contains the complete text of the message. The "type" key is the message type ('plain' or 'html'). The 'html' type should be used when generating an HTML message. The optional "subject" key gives the subject for the email.
  • extraHeaders (dict) - 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.
  • useTls (boolean) - Send emails using TLS and authenticate with the smtp host. Defaults to False.
  • smtpUser (string) - The user that will attempt to authenticate with the relayhost when useTls is True.
  • smtpPassword (string) - The password that smtpUser will use when authenticating with relayhost.
  • smtpPort (int) - The port that will be used when connecting to the relayhost. Defaults to 25.
Overrides: twisted.application.service.MultiService.__init__

setServiceParent(self, parent)

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

startService(self)

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

stopService(self)

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

disownServiceParent(self)

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

builderAdded(self, name, builder)

source code 
Overrides: base.StatusReceiverBase.builderAdded

builderRemoved(self, name)

source code 
Overrides: base.StatusReceiverBase.builderRemoved

builderChangedState(self, name, state)

source code 
Overrides: base.StatusReceiverBase.builderChangedState

buildStarted(self, name, build)

source code 
Overrides: base.StatusReceiverBase.buildStarted

buildFinished(self, name, build, results)

source code 
Overrides: base.StatusReceiverBase.buildFinished

__provides__(...)

 

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

Overrides: twisted.application.service.Service.__provides__

Class Variable Details

compare_attrs

Value:
['extraRecipients',
 'lookup',
 'fromaddr',
 'mode',
 'categories',
 'builders',
 'addLogs',
 'relayhost',
...

possible_modes

Value:
('change', 'failing', 'passing', 'problem', 'warnings', 'exception')

__implemented__

Value:
<implementedBy buildbot.status.mail.MailNotifier>