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:
templateIf 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’.
subjectThe 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
want_propertiesThis parameter (defaults to True) will extend the content of the given
buildobject with the Properties from the build.wantPropertiesDeprecated, use
want_propertiesset to the same value.want_stepsThis 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 terms of CPU and memory on the master.wantStepsDeprecated, use
want_stepsset to the same value.wantLogsDeprecated, use
want_logsandwant_logs_contentset to the same value.want_logsThis parameter (defaults to False) will extend the content of the steps of the given
buildobject with the log metadata of each steps from the build. This implieswantStepsto be True. Use it only when mandatory, as this greatly increases the overhead in terms of CPU and memory on the master.want_logs_contentThis parameter (defaults to False) will extend the content of the logs with the log contents of each steps from the build. This implies
want_logsandwantStepsto be True. Use it only when mandatory, as this greatly increases the overhead in terms of CPU and memory on the master.
Context¶
The context that is given to the template consists of the following data:
resultsThe results of the build. Equivalent to
build['results'].buildernameThe name of the builder. Equivalent to
build['builder']['name']modeThe mode argument that has been passed to the report generator.
workernameThe name of the worker. Equivalent to the
workernameproperty of the build or<unknown>if it’s not available.buildsetThe
buildsetdictionary from data API.buildThe
builddictionary from data API. Thepropertiesattribute is populated only ifwant_propertiesis set toTrue. It has the following extra properties:builderThe
builderdictionary from the data API that describes the builder of the build.buildrequestThe
buildrequestdictionary from the data API that describes the build request that the build was built for.buildsetThe
buildsetdictionary from the data API that describes the buildset that the build was built for.parentbuildThe
builddictionary from the data API that describes the parent build. This build is identified by theparent_buildidattribute of the buildset.parentbuilderThe
builderdictionary from the data API that describes the builder of the parent build.urlURL to the build in the Buildbot UI.
prev_buildThe
builddictionary from the data API that describes previous build, if any. This attribute is populated only ifwantPreviousBuildis set toTrue.stepsA list of
stepdictionaries from the data API that describe steps in the build, if any. This attribute is populated only ifwantStepsis set toTrue.Additionally, if
want_logsis set toTruethen the step dictionaries will containlogsattribute with a list oflogdictionaries from the data API that describe the logs of the step. The log dictionaries will additionally containurlkey with URL to the log in the web UI as the value.Additionally, if
want_logs_contentis set toTruethen the log dictionaries will containcontentskey with full contents of the log.
projectsA string identifying the projects that the build was built for.
previous_resultsResults of the previous build, if available, otherwise
None.status_detectedString that describes the build in terms of current build results, previous build results and
mode.build_urlURL to the build in the Buildbot UI.
buildbot_urlURL to the Buildbot instance.
blamelistThe list of users responsible for the build.
summaryA string that summarizes the build result.
sourcestampsA string identifying the source stamps for which the build was made.
Examples¶
The following examples describe 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(', ') }}