Caution
Buildbot no longer supports Python 2.7 on the Buildbot master.
2.5.13.5. MessageFormatter¶
This formatter is used to format messages in BuildStatusGenerator and BuildSetStatusGenerator.
It formats a message using the Jinja2 templating language and picks the template either from a string or from a file.
The constructor of the class takes the following arguments:
template_dirThe directory that is used to look for the various templates. This argument is deprecated, please supply message templates as
templatedirectly.template_filenameThis is the name of the file in the
template_dirdirectory that will be used to generate the body of the mail. It defaults todefault_mail.txt. This argument is deprecated, please supply message templates astemplatedirectly.templateIf this parameter is set, this parameter indicates the content of the template used to generate the body of the mail as string.
template_typeThis indicates the type of the generated template. Use either ‘plain’ (the default) or ‘html’.
subject_filenameThis is the name of the file in the
template_dirdirectory that contains the content of the subject of the mail. This argument is deprecated, please supply message templates assubjectdirectly.subjectAlternatively, this is the content of the subject of the mail as string.
ctxThis is an extension of the standard context that will be given to the templates. Use this to add content to the templates that is otherwise not available.
Alternatively, you can subclass MessageFormatter and override the
buildAdditionalContextin order to grab more context from the data API.-
buildbot.reporters.message.buildAdditionalContext(master, ctx) - Parameters
master – the master object
ctx – the context dictionary to enhance
- Returns
optionally deferred
default implementation will add
self.ctxinto the current template context
-
wantPropertiesThis parameter (defaults to True) will extend the content of the given
buildobject with the Properties from the build.wantStepsThis parameter (defaults to False) will extend the content of the given
buildobject with information about the steps of the build. Use it only when necessary as this increases the overhead in term of CPU and memory on the master.wantLogsThis parameter (defaults to False) will extend the content of the steps of the given
buildobject with the full Logs of each steps from the build. This requireswantStepsto be True. Use it only when mandatory as this increases the overhead in term of CPU and memory on the master greatly.
Context
The context that is given to the template consists of the following data:
The following table describes how to get some useful pieces of information from the various data objects:
- Name of the builder that generated this event
{{ buildername }}- Title of the BuildMaster
{{ projects }}- MailNotifier mode
{{ mode }}(a combination ofchange,failing,passing,problem,warnings,exception,all)- URL to build page
{{ build_url }}- URL to Buildbot main page
{{ buildbot_url }}- Status of the build as string.
This require extending the context of the Formatter via the
ctxparameter with:ctx=dict(statuses=util.Results).{{ statuses[results] }}- Build text
{{ build['state_string'] }}- Mapping of property names to (values, source)
{{ build['properties'] }}- For instance the build reason (from a forced build)
{{ build['properties']['reason'][0] }}- Worker name
{{ workername }}- List of responsible users
{{ blamelist | join(', ') }}