blob: 62d021911623a5176f8a1c9fc94e8a7f4dba3ecf [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001= Gerrit Code Review - Mail Templates
Martin Fickb7f3b2d2010-07-23 10:23:03 -06002
3Gerrit uses velocity templates for the bulk of the standard mails it sends out.
4There are builtin default templates which are used if they are not overridden.
5These defaults are also provided as examples so that administrators may copy
6them and easily modify them to tweak their contents.
7
8
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08009== Template Locations and Extensions:
Martin Fickb7f3b2d2010-07-23 10:23:03 -060010
11The default example templates reside under: `'$site_path'/etc/mail` and are
12terminated with the double extension `.vm.example`. Modifying these example
13files will have no effect on the behavior of Gerrit. However, copying an
14example template to an equivalently named file without the `.example` extension
15and modifying it will allow an administrator to customize the template.
16
17
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080018== Supported Mail Templates:
Martin Fickb7f3b2d2010-07-23 10:23:03 -060019
David Pursehouse221d4f62012-06-08 17:38:08 +090020Each mail that Gerrit sends out is controlled by at least one template. These
Martin Fickb7f3b2d2010-07-23 10:23:03 -060021are listed below. Change emails are influenced by two additional templates,
22one to set the subject line, and one to set the footer which gets appended to
23all the change emails (see `ChangeSubject.vm` and `ChangeFooter.vm` below.)
24
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080025=== Abandoned.vm
Martin Fick40ed99f2010-07-21 11:46:21 -060026
27The `Abandoned.vm` template will determine the contents of the email related
28to a change being abandoned. It is a `ChangeEmail`: see `ChangeSubject.vm` and
29`ChangeFooter.vm`.
30
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080031=== ChangeFooter.vm
Martin Fick82bd12c2010-07-21 11:46:21 -060032
33The `ChangeFooter.vm` template will determine the contents of the footer
David Pursehouse221d4f62012-06-08 17:38:08 +090034text that will be appended to emails related to changes (all `ChangeEmail`s).
Martin Fick82bd12c2010-07-21 11:46:21 -060035
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080036=== ChangeSubject.vm
Martin Fickb7f3b2d2010-07-23 10:23:03 -060037
38The `ChangeSubject.vm` template will determine the contents of the email
39subject line for ALL emails related to changes.
40
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080041=== Comment.vm
Martin Fick382e0a82010-07-27 17:09:33 -060042
43The `Comment.vm` template will determine the contents of the email related to
44a user submitting comments on changes. It is a `ChangeEmail`: see
David Pursehouse85287c12012-09-24 20:58:21 +090045`ChangeSubject.vm`, `ChangeFooter.vm` and `CommentFooter.vm`.
46
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080047=== CommentFooter.vm
David Pursehouse85287c12012-09-24 20:58:21 +090048
49The `CommentFooter.vm` template will determine the contents of the footer
50text that will be appended to emails related to a user submitting comments on
51changes. See `ChangeSubject.vm`, `Comment.vm` and `ChangeFooter.vm`.
Martin Fick382e0a82010-07-27 17:09:33 -060052
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080053=== Footer.vm
David Pursehouse7a1d7c02013-06-05 12:22:45 +090054
55The `Footer.vm` template will determine the contents of the footer text
56appended to the end of all outgoing emails after the ChangeFooter and
57CommentFooter.
58
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080059=== Merged.vm
Martin Fick7305be42010-07-23 17:31:26 -060060
61The `Merged.vm` template will determine the contents of the email related to
62a change successfully merged to the head. It is a `ChangeEmail`: see
63`ChangeSubject.vm` and `ChangeFooter.vm`.
64
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080065=== MergeFail.vm
Martin Fick40ed99f2010-07-21 11:46:21 -060066
67The `MergeFail.vm` template will determine the contents of the email related
68to a failure upon attempting to merge a change to the head. It is a
David Pursehouse221d4f62012-06-08 17:38:08 +090069`ChangeEmail`: see `ChangeSubject.vm` and `ChangeFooter.vm`.
Martin Fick679fc372010-07-21 11:46:21 -060070
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080071=== NewChange.vm
Martin Fick679fc372010-07-21 11:46:21 -060072
73The `NewChange.vm` template will determine the contents of the email related
David Pursehouse5fb9e3e2013-07-10 17:19:35 +090074to a user submitting a new change for review. This includes changes created
75by actions made by the user in the Web UI such as cherry picking a commit or
76reverting a change. It is a `ChangeEmail`: see `ChangeSubject.vm` and
77`ChangeFooter.vm`.
Martin Fick679fc372010-07-21 11:46:21 -060078
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080079=== RegisterNewEmail.vm
Martin Fick679fc372010-07-21 11:46:21 -060080
81The `RegisterNewEmail.vm` template will determine the contents of the email
82related to registering new email accounts.
83
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080084=== ReplacePatchSet.vm
Martin Fick679fc372010-07-21 11:46:21 -060085
86The `ReplacePatchSet.vm` template will determine the contents of the email
David Pursehouse5fb9e3e2013-07-10 17:19:35 +090087related to a user submitting a new patchset for a change. This includes
88patchsets created by actions made by the user in the Web UI such as editing
89the commit message, cherry picking a commit, or rebasing a change. It is a
Martin Fick40ed99f2010-07-21 11:46:21 -060090`ChangeEmail`: see `ChangeSubject.vm` and `ChangeFooter.vm`.
91
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080092=== Restored.vm
Martin Fick7759a6f2011-06-27 10:25:38 -060093
94The `Restored.vm` template will determine the contents of the email related
95to a change being restored. It is a `ChangeEmail`: see `ChangeSubject.vm` and
96`ChangeFooter.vm`.
97
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080098=== Reverted.vm
David Pursehouse8f4e01f2012-09-27 20:53:22 +090099
100The `Reverted.vm` template will determine the contents of the email related
101to a change being reverted. It is a `ChangeEmail`: see `ChangeSubject.vm` and
102`ChangeFooter.vm`.
Martin Fick7759a6f2011-06-27 10:25:38 -0600103
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600104
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800105== Mail Variables and Methods
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600106
107Mail templates can access and display objects currently made available to them
108via the velocity context. While the base objects are documented here, it is
109possible to call public methods on these objects from templates. Those methods
110are not documented here since they could change with every release. As these
111templates are meant to be modified only by a qualified sysadmin, it is accepted
112that writing templates for Gerrit emails is likely to require some basic
113knowledge of the class structure to be useful. Browsing the source code might
114be necessary for anything more than a minor formatting change.
115
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800116=== Warning
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600117
David Pursehouse221d4f62012-06-08 17:38:08 +0900118Be aware that modifying templates can cause them to fail to parse and therefore
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600119not send out the actual email, or worse, calling methods on the available
120objects could have internal side effects which would adversely affect the
121health of your Gerrit server and/or data.
122
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800123=== All OutgoingEmails
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600124
125All outgoing emails have the following variables available to them:
126
127$email::
128+
129A reference to the class constructing the current `OutgoingEmail`. With this
130reference it is possible to call any public method on the OutgoingEmail class
131or the current child class inherited from it.
132
133$messageClass::
134+
David Pursehouse221d4f62012-06-08 17:38:08 +0900135A String containing the messageClass.
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600136
137$StringUtils::
138+
139A reference to the Apache `StringUtils` class. This can be very useful for
140formatting strings.
141
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800142=== Change Emails
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600143
144All change related emails have the following additional variables available to them:
145
146$change::
147+
David Pursehouse221d4f62012-06-08 17:38:08 +0900148A reference to the current `Change` object.
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600149
150$changeId::
151+
David Pursehouse221d4f62012-06-08 17:38:08 +0900152Id of the current change (a `Change.Key`).
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600153
154$coverLetter::
155+
David Pursehouse221d4f62012-06-08 17:38:08 +0900156The text of the `ChangeMessage`.
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600157
158$branch::
159+
David Pursehouse221d4f62012-06-08 17:38:08 +0900160A reference to the branch of this change (a `Branch.NameKey`).
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600161
162$fromName::
163+
David Pursehouse221d4f62012-06-08 17:38:08 +0900164The name of the from user.
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600165
166$projectName::
167+
David Pursehouse221d4f62012-06-08 17:38:08 +0900168The name of this change's project.
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600169
170$patchSet::
171+
David Pursehouse221d4f62012-06-08 17:38:08 +0900172A reference to the current `PatchSet`.
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600173
174$patchSetInfo::
175+
David Pursehouse221d4f62012-06-08 17:38:08 +0900176A reference to the current `PatchSetInfo`.
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600177
178
Fredrik Luthandera6bb9512014-03-24 18:59:45 -0700179== SEE ALSO
Martin Fickb7f3b2d2010-07-23 10:23:03 -0600180
181* link:http://velocity.apache.org/[velocity]
182
183GERRIT
184------
185Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700186
187SEARCHBOX
188---------