Update email template docs to reflect updated template system
Update the email template documentation to reflect the updated template system and template data keys. Change-Id: Ib36c37165ffea4a8f8bfb252848b0c6cc19c0cff
This commit is contained in:
parent
0457e24291
commit
bf0502cb58
@ -1,163 +1,160 @@
|
|||||||
= Gerrit Code Review - Mail Templates
|
= Gerrit Code Review - Mail Templates
|
||||||
|
|
||||||
Gerrit uses velocity templates for the bulk of the standard mails it sends out.
|
Gerrit uses Closure Templates for the bulk of the standard mails it sends out.
|
||||||
There are builtin default templates which are used if they are not overridden.
|
There are builtin default templates which are used if they are not overridden.
|
||||||
These defaults are also provided as examples so that administrators may copy
|
These defaults are also provided as examples so that administrators may copy
|
||||||
them and easily modify them to tweak their contents.
|
them and easily modify them to tweak their contents.
|
||||||
|
|
||||||
|
*Compatibility Note:* previously, Velocity Template Language (VTL) was used as
|
||||||
|
the template language for Gerrit emails. VTL has now been deprecated in favor of
|
||||||
|
Soy, but Velocity templates that modify text emails remain supported for now.
|
||||||
|
|
||||||
== Template Locations and Extensions:
|
== Template Locations and Extensions:
|
||||||
|
|
||||||
The default example templates reside under: `'$site_path'/etc/mail` and are
|
The default example templates reside under: `'$site_path'/etc/mail` and are
|
||||||
terminated with the double extension `.vm.example`. Modifying these example
|
terminated with the double extension `.soy.example`. Modifying these example
|
||||||
files will have no effect on the behavior of Gerrit. However, copying an
|
files will have no effect on the behavior of Gerrit. However, copying an
|
||||||
example template to an equivalently named file without the `.example` extension
|
example template to an equivalently named file without the `.example` extension
|
||||||
and modifying it will allow an administrator to customize the template.
|
and modifying it will allow an administrator to customize the template.
|
||||||
|
|
||||||
|
|
||||||
== Supported Mail Templates:
|
== Supported Mail Templates:
|
||||||
|
|
||||||
Each mail that Gerrit sends out is controlled by at least one template. These
|
Each mail that Gerrit sends out is controlled by at least one template. These
|
||||||
are listed below. Change emails are influenced by two additional templates,
|
are listed below. Change emails are influenced by two additional templates,
|
||||||
one to set the subject line, and one to set the footer which gets appended to
|
one to set the subject line, and one to set the footer which gets appended to
|
||||||
all the change emails (see `ChangeSubject.vm` and `ChangeFooter.vm` below.)
|
all the change emails (see `ChangeSubject.soy` and `ChangeFooter.soy` below.)
|
||||||
|
|
||||||
=== Abandoned.vm
|
Many types of Gerrit email message support HTML in addition to plain-text. Where
|
||||||
|
both are supported, templates to control the HTML part have `...Html` appended
|
||||||
|
in their file names. For example, for "Abandoned" emails, the `Abandoned.soy`
|
||||||
|
template determines the text part of the message, whereas `AbandonedHtml.soy`
|
||||||
|
determines the HTML part.
|
||||||
|
|
||||||
The `Abandoned.vm` template will determine the contents of the email related
|
=== Abandoned.soy and AbandonedHtml.soy
|
||||||
to a change being abandoned. It is a `ChangeEmail`: see `ChangeSubject.vm` and
|
|
||||||
`ChangeFooter.vm`.
|
|
||||||
|
|
||||||
=== AddKey.vm
|
The "Abandoned" templates will determine the contents of the email related to a
|
||||||
|
change being abandoned. It is a `ChangeEmail`: see `ChangeSubject.soy` and
|
||||||
|
ChangeFooter.
|
||||||
|
|
||||||
The `AddKey.vm` template will determine the contents of the email related to
|
=== AddKey.soy and AddKeyHtml.soy
|
||||||
SSH and GPG keys being added to a user account. This notification is not sent
|
|
||||||
when the key is administratively added to another user account.
|
|
||||||
|
|
||||||
=== ChangeFooter.vm
|
AddKey templates will determine the contents of the email related to SSH and GPG
|
||||||
|
keys being added to a user account. This notification is not sent when the key
|
||||||
|
is administratively added to another user account.
|
||||||
|
|
||||||
The `ChangeFooter.vm` template will determine the contents of the footer
|
=== ChangeFooter.soy and ChangeFooterHtml.soy
|
||||||
text that will be appended to emails related to changes (all `ChangeEmail`s).
|
|
||||||
|
|
||||||
=== ChangeSubject.vm
|
The ChangeFooter templates will determine the contents of the footer that will
|
||||||
|
be appended to emails related to changes (all `ChangeEmail`s).
|
||||||
|
|
||||||
The `ChangeSubject.vm` template will determine the contents of the email
|
=== ChangeSubject.soy
|
||||||
|
|
||||||
|
The `ChangeSubject.soy` template will determine the contents of the email
|
||||||
subject line for ALL emails related to changes.
|
subject line for ALL emails related to changes.
|
||||||
|
|
||||||
=== Comment.vm
|
=== Comment.soy
|
||||||
|
|
||||||
The `Comment.vm` template will determine the contents of the email related to
|
The `Comment.soy` template will determine the contents of the email related to
|
||||||
a user submitting comments on changes. It is a `ChangeEmail`: see
|
a user submitting comments on changes. It is a `ChangeEmail`: see
|
||||||
`ChangeSubject.vm`, `ChangeFooter.vm` and `CommentFooter.vm`.
|
`ChangeSubject.soy`, ChangeFooter and CommentFooter.
|
||||||
|
|
||||||
=== CommentFooter.vm
|
=== CommentFooter.soy and CommentFooterHtml.soy
|
||||||
|
|
||||||
The `CommentFooter.vm` template will determine the contents of the footer
|
The CommentFooter templates will determine the contents of the footer text that
|
||||||
text that will be appended to emails related to a user submitting comments on
|
will be appended to emails related to a user submitting comments on changes.
|
||||||
changes. See `ChangeSubject.vm`, `Comment.vm` and `ChangeFooter.vm`.
|
See `ChangeSubject.soy`, Comment and ChangeFooter.
|
||||||
|
|
||||||
=== DeleteVote.vm
|
=== DeleteVote.soy and DeleteVoteHtml.soy
|
||||||
|
|
||||||
The `DeleteVote.vm` template will determine the contents of the email related
|
The DeleteVote templates will determine the contents of the email related to
|
||||||
to removing votes on changes. It is a `ChangeEmail`: see `ChangeSubject.vm`
|
removing votes on changes. It is a `ChangeEmail`: see `ChangeSubject.soy`
|
||||||
and `ChangeFooter.vm`.
|
and ChangeFooter.
|
||||||
|
|
||||||
=== DeleteReviewer.vm
|
=== DeleteReviewer.soy and DeleteReviewerHtml.soy
|
||||||
|
|
||||||
The `DeleteReviewer.vm` template will determine the contents of the email related
|
The DeleteReviewer templates will determine the contents of the email related to
|
||||||
to a user removing a reviewer (with a vote) from a change. It is a
|
a user removing a reviewer (with a vote) from a change. It is a
|
||||||
`ChangeEmail`: see `ChangeSubject.vm` and `ChangeFooter.vm`.
|
`ChangeEmail`: see `ChangeSubject.soy` and ChangeFooter.
|
||||||
|
|
||||||
=== Footer.vm
|
=== Footer.soy and FooterHtml.soy
|
||||||
|
|
||||||
The `Footer.vm` template will determine the contents of the footer text
|
The Footer templates will determine the contents of the footer text appended to
|
||||||
appended to the end of all outgoing emails after the ChangeFooter and
|
the end of all outgoing emails after the ChangeFooter and CommentFooter.
|
||||||
CommentFooter.
|
|
||||||
|
|
||||||
=== Merged.vm
|
=== Merged.soy and MergedHtml.soy
|
||||||
|
|
||||||
The `Merged.vm` template will determine the contents of the email related to
|
The Merged templates will determine the contents of the email related to a
|
||||||
a change successfully merged to the head. It is a `ChangeEmail`: see
|
change successfully merged to the head. It is a `ChangeEmail`: see
|
||||||
`ChangeSubject.vm` and `ChangeFooter.vm`.
|
`ChangeSubject.soy` and ChangeFooter.
|
||||||
|
|
||||||
=== NewChange.vm
|
=== NewChange.soy and NewChangeHtml.soy
|
||||||
|
|
||||||
The `NewChange.vm` template will determine the contents of the email related
|
The NewChange templates will determine the contents of the email related to a
|
||||||
to a user submitting a new change for review. This includes changes created
|
user submitting a new change for review. This includes changes created by
|
||||||
by actions made by the user in the Web UI such as cherry picking a commit or
|
actions made by the user in the Web UI such as cherry picking a commit or
|
||||||
reverting a change. It is a `ChangeEmail`: see `ChangeSubject.vm` and
|
reverting a change. It is a `ChangeEmail`: see `ChangeSubject.soy` and
|
||||||
`ChangeFooter.vm`.
|
ChangeFooter.
|
||||||
|
|
||||||
=== RegisterNewEmail.vm
|
=== RegisterNewEmail.soy
|
||||||
|
|
||||||
The `RegisterNewEmail.vm` template will determine the contents of the email
|
The `RegisterNewEmail.soy` template will determine the contents of the email
|
||||||
related to registering new email accounts.
|
related to registering new email accounts.
|
||||||
|
|
||||||
=== ReplacePatchSet.vm
|
=== ReplacePatchSet.soy and ReplacePatchSetHtml.soy
|
||||||
|
|
||||||
The `ReplacePatchSet.vm` template will determine the contents of the email
|
The ReplacePatchSet templates will determine the contents of the email related
|
||||||
related to a user submitting a new patchset for a change. This includes
|
to a user submitting a new patchset for a change. This includes patchsets
|
||||||
patchsets created by actions made by the user in the Web UI such as editing
|
created by actions made by the user in the Web UI such as editing the commit
|
||||||
the commit message, cherry picking a commit, or rebasing a change. It is a
|
message, cherry picking a commit, or rebasing a change. It is a `ChangeEmail`:
|
||||||
`ChangeEmail`: see `ChangeSubject.vm` and `ChangeFooter.vm`.
|
see `ChangeSubject.soy` and ChangeFooter.
|
||||||
|
|
||||||
=== Restored.vm
|
=== Restored.soy and RestoredHtml.soy
|
||||||
|
|
||||||
The `Restored.vm` template will determine the contents of the email related
|
The Restored templates will determine the contents of the email related to a
|
||||||
to a change being restored. It is a `ChangeEmail`: see `ChangeSubject.vm` and
|
change being restored. It is a `ChangeEmail`: see `ChangeSubject.soy` and
|
||||||
`ChangeFooter.vm`.
|
ChangeFooter.
|
||||||
|
|
||||||
=== Reverted.vm
|
=== Reverted.soy and RevertedHtml.soy
|
||||||
|
|
||||||
The `Reverted.vm` template will determine the contents of the email related
|
The Reverted templates will determine the contents of the email related to a
|
||||||
to a change being reverted. It is a `ChangeEmail`: see `ChangeSubject.vm` and
|
change being reverted. It is a `ChangeEmail`: see `ChangeSubject.soy` and
|
||||||
`ChangeFooter.vm`.
|
ChangeFooter.
|
||||||
|
|
||||||
|
|
||||||
== Mail Variables and Methods
|
== Mail Variables and Methods
|
||||||
|
|
||||||
Mail templates can access and display objects currently made available to them
|
Mail templates can access and display objects currently made available to them
|
||||||
via the velocity context. While the base objects are documented here, it is
|
via the Soy context.
|
||||||
possible to call public methods on these objects from templates. Those methods
|
|
||||||
are not documented here since they could change with every release. As these
|
|
||||||
templates are meant to be modified only by a qualified sysadmin, it is accepted
|
|
||||||
that writing templates for Gerrit emails is likely to require some basic
|
|
||||||
knowledge of the class structure to be useful. Browsing the source code might
|
|
||||||
be necessary for anything more than a minor formatting change.
|
|
||||||
|
|
||||||
=== Warning
|
=== Warning
|
||||||
|
|
||||||
Be aware that modifying templates can cause them to fail to parse and therefore
|
Be aware that modifying templates can cause them to fail to parse and therefore
|
||||||
not send out the actual email, or worse, calling methods on the available
|
not send out the actual email.
|
||||||
objects could have internal side effects which would adversely affect the
|
|
||||||
health of your Gerrit server and/or data.
|
|
||||||
|
|
||||||
=== All OutgoingEmails
|
=== All OutgoingEmails
|
||||||
|
|
||||||
All outgoing emails have the following variables available to them:
|
All outgoing emails have the following variables available to them:
|
||||||
|
|
||||||
$email::
|
$email.settingsUrl::
|
||||||
+
|
+
|
||||||
A reference to the class constructing the current `OutgoingEmail`. With this
|
The URL to view the user's settings in the Gerrit web UI.
|
||||||
reference it is possible to call any public method on the OutgoingEmail class
|
|
||||||
or the current child class inherited from it.
|
$email.gerritHost::
|
||||||
|
+
|
||||||
|
The name of the Gerrit instance.
|
||||||
|
|
||||||
|
$email.gerritUrl::
|
||||||
|
+
|
||||||
|
The URL to the Gerrit web UI.
|
||||||
|
|
||||||
$messageClass::
|
$messageClass::
|
||||||
+
|
+
|
||||||
A String containing the messageClass.
|
A String containing the messageClass.
|
||||||
|
|
||||||
$StringUtils::
|
|
||||||
+
|
|
||||||
A reference to the Apache `StringUtils` class. This can be very useful for
|
|
||||||
formatting strings.
|
|
||||||
|
|
||||||
=== Change Emails
|
=== Change Emails
|
||||||
|
|
||||||
All change related emails have the following additional variables available to them:
|
Change related emails have the following template data available to them, in
|
||||||
|
addition to what's available to all outgoing emails.
|
||||||
$change::
|
|
||||||
+
|
|
||||||
A reference to the current `Change` object.
|
|
||||||
|
|
||||||
$changeId::
|
$changeId::
|
||||||
+
|
+
|
||||||
@ -167,30 +164,69 @@ $coverLetter::
|
|||||||
+
|
+
|
||||||
The text of the `ChangeMessage`.
|
The text of the `ChangeMessage`.
|
||||||
|
|
||||||
$branch::
|
|
||||||
+
|
|
||||||
A reference to the branch of this change (a `Branch.NameKey`).
|
|
||||||
|
|
||||||
$fromName::
|
$fromName::
|
||||||
+
|
+
|
||||||
The name of the from user.
|
The name of the from user.
|
||||||
|
|
||||||
|
$email.unifiedDiff::
|
||||||
|
+
|
||||||
|
The diff of the change.
|
||||||
|
|
||||||
|
$email.changeDetail::
|
||||||
|
+
|
||||||
|
The details of the change, including the commit message.
|
||||||
|
|
||||||
|
$email.changeUrl::
|
||||||
|
+
|
||||||
|
The URL to the change in the web UI.
|
||||||
|
|
||||||
|
$email.includeDiff::
|
||||||
|
+
|
||||||
|
Whether the Gerrit instance is configured to include diffs in emails.
|
||||||
|
|
||||||
|
$change.subject::
|
||||||
|
+
|
||||||
|
The subject of the current change.
|
||||||
|
|
||||||
|
$change.originalSubject::
|
||||||
|
+
|
||||||
|
The subject corresponding to the first patch set of the current change.
|
||||||
|
|
||||||
|
$change.shortSubject::
|
||||||
|
+
|
||||||
|
The subject limited to 63 characters, with an ellipsis if it exceeds that.
|
||||||
|
|
||||||
|
$change.ownerEmail::
|
||||||
|
+
|
||||||
|
The email address of the owner of the change.
|
||||||
|
|
||||||
|
$branch.shortName::
|
||||||
|
+
|
||||||
|
The name of the branch targeted by the current change.
|
||||||
|
|
||||||
$projectName::
|
$projectName::
|
||||||
+
|
+
|
||||||
The name of this change's project.
|
The name of this change's project.
|
||||||
|
|
||||||
$patchSet::
|
$shortProjectName::
|
||||||
+
|
+
|
||||||
A reference to the current `PatchSet`.
|
The project name with the path abbreviated.
|
||||||
|
|
||||||
$patchSetInfo::
|
$sshHost::
|
||||||
+
|
+
|
||||||
A reference to the current `PatchSetInfo`.
|
SSH hostname for the Gerrit instance.
|
||||||
|
|
||||||
|
$patchSet.patchSetId::
|
||||||
|
+
|
||||||
|
The current patch set number.
|
||||||
|
|
||||||
|
$patchSet.refname::
|
||||||
|
+
|
||||||
|
The refname of the patch set.
|
||||||
|
|
||||||
== SEE ALSO
|
== SEE ALSO
|
||||||
|
|
||||||
* link:http://velocity.apache.org/[velocity]
|
* link:https://developers.google.com/closure/templates/[Closure Templates]
|
||||||
|
|
||||||
GERRIT
|
GERRIT
|
||||||
------
|
------
|
||||||
|
Loading…
Reference in New Issue
Block a user