Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 1 | = Gerrit Code Review - Mail Templates |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 2 | |
| 3 | Gerrit uses velocity templates for the bulk of the standard mails it sends out. |
| 4 | There are builtin default templates which are used if they are not overridden. |
| 5 | These defaults are also provided as examples so that administrators may copy |
| 6 | them and easily modify them to tweak their contents. |
| 7 | |
| 8 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 9 | == Template Locations and Extensions: |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 10 | |
| 11 | The default example templates reside under: `'$site_path'/etc/mail` and are |
| 12 | terminated with the double extension `.vm.example`. Modifying these example |
| 13 | files will have no effect on the behavior of Gerrit. However, copying an |
| 14 | example template to an equivalently named file without the `.example` extension |
| 15 | and modifying it will allow an administrator to customize the template. |
| 16 | |
| 17 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 18 | == Supported Mail Templates: |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 19 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 20 | Each mail that Gerrit sends out is controlled by at least one template. These |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 21 | are listed below. Change emails are influenced by two additional templates, |
| 22 | one to set the subject line, and one to set the footer which gets appended to |
| 23 | all the change emails (see `ChangeSubject.vm` and `ChangeFooter.vm` below.) |
| 24 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 25 | === Abandoned.vm |
Martin Fick | 40ed99f | 2010-07-21 11:46:21 -0600 | [diff] [blame] | 26 | |
| 27 | The `Abandoned.vm` template will determine the contents of the email related |
| 28 | to a change being abandoned. It is a `ChangeEmail`: see `ChangeSubject.vm` and |
| 29 | `ChangeFooter.vm`. |
| 30 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 31 | === ChangeFooter.vm |
Martin Fick | 82bd12c | 2010-07-21 11:46:21 -0600 | [diff] [blame] | 32 | |
| 33 | The `ChangeFooter.vm` template will determine the contents of the footer |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 34 | text that will be appended to emails related to changes (all `ChangeEmail`s). |
Martin Fick | 82bd12c | 2010-07-21 11:46:21 -0600 | [diff] [blame] | 35 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 36 | === ChangeSubject.vm |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 37 | |
| 38 | The `ChangeSubject.vm` template will determine the contents of the email |
| 39 | subject line for ALL emails related to changes. |
| 40 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 41 | === Comment.vm |
Martin Fick | 382e0a8 | 2010-07-27 17:09:33 -0600 | [diff] [blame] | 42 | |
| 43 | The `Comment.vm` template will determine the contents of the email related to |
| 44 | a user submitting comments on changes. It is a `ChangeEmail`: see |
David Pursehouse | 85287c1 | 2012-09-24 20:58:21 +0900 | [diff] [blame] | 45 | `ChangeSubject.vm`, `ChangeFooter.vm` and `CommentFooter.vm`. |
| 46 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 47 | === CommentFooter.vm |
David Pursehouse | 85287c1 | 2012-09-24 20:58:21 +0900 | [diff] [blame] | 48 | |
| 49 | The `CommentFooter.vm` template will determine the contents of the footer |
| 50 | text that will be appended to emails related to a user submitting comments on |
| 51 | changes. See `ChangeSubject.vm`, `Comment.vm` and `ChangeFooter.vm`. |
Martin Fick | 382e0a8 | 2010-07-27 17:09:33 -0600 | [diff] [blame] | 52 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 53 | === Footer.vm |
David Pursehouse | 7a1d7c0 | 2013-06-05 12:22:45 +0900 | [diff] [blame] | 54 | |
| 55 | The `Footer.vm` template will determine the contents of the footer text |
| 56 | appended to the end of all outgoing emails after the ChangeFooter and |
| 57 | CommentFooter. |
| 58 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 59 | === Merged.vm |
Martin Fick | 7305be4 | 2010-07-23 17:31:26 -0600 | [diff] [blame] | 60 | |
| 61 | The `Merged.vm` template will determine the contents of the email related to |
| 62 | a change successfully merged to the head. It is a `ChangeEmail`: see |
| 63 | `ChangeSubject.vm` and `ChangeFooter.vm`. |
| 64 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 65 | === MergeFail.vm |
Martin Fick | 40ed99f | 2010-07-21 11:46:21 -0600 | [diff] [blame] | 66 | |
| 67 | The `MergeFail.vm` template will determine the contents of the email related |
| 68 | to a failure upon attempting to merge a change to the head. It is a |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 69 | `ChangeEmail`: see `ChangeSubject.vm` and `ChangeFooter.vm`. |
Martin Fick | 679fc37 | 2010-07-21 11:46:21 -0600 | [diff] [blame] | 70 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 71 | === NewChange.vm |
Martin Fick | 679fc37 | 2010-07-21 11:46:21 -0600 | [diff] [blame] | 72 | |
| 73 | The `NewChange.vm` template will determine the contents of the email related |
David Pursehouse | 5fb9e3e | 2013-07-10 17:19:35 +0900 | [diff] [blame] | 74 | to a user submitting a new change for review. This includes changes created |
| 75 | by actions made by the user in the Web UI such as cherry picking a commit or |
| 76 | reverting a change. It is a `ChangeEmail`: see `ChangeSubject.vm` and |
| 77 | `ChangeFooter.vm`. |
Martin Fick | 679fc37 | 2010-07-21 11:46:21 -0600 | [diff] [blame] | 78 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 79 | === RegisterNewEmail.vm |
Martin Fick | 679fc37 | 2010-07-21 11:46:21 -0600 | [diff] [blame] | 80 | |
| 81 | The `RegisterNewEmail.vm` template will determine the contents of the email |
| 82 | related to registering new email accounts. |
| 83 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 84 | === ReplacePatchSet.vm |
Martin Fick | 679fc37 | 2010-07-21 11:46:21 -0600 | [diff] [blame] | 85 | |
| 86 | The `ReplacePatchSet.vm` template will determine the contents of the email |
David Pursehouse | 5fb9e3e | 2013-07-10 17:19:35 +0900 | [diff] [blame] | 87 | related to a user submitting a new patchset for a change. This includes |
| 88 | patchsets created by actions made by the user in the Web UI such as editing |
| 89 | the commit message, cherry picking a commit, or rebasing a change. It is a |
Martin Fick | 40ed99f | 2010-07-21 11:46:21 -0600 | [diff] [blame] | 90 | `ChangeEmail`: see `ChangeSubject.vm` and `ChangeFooter.vm`. |
| 91 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 92 | === Restored.vm |
Martin Fick | 7759a6f | 2011-06-27 10:25:38 -0600 | [diff] [blame] | 93 | |
| 94 | The `Restored.vm` template will determine the contents of the email related |
| 95 | to a change being restored. It is a `ChangeEmail`: see `ChangeSubject.vm` and |
| 96 | `ChangeFooter.vm`. |
| 97 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 98 | === Reverted.vm |
David Pursehouse | 8f4e01f | 2012-09-27 20:53:22 +0900 | [diff] [blame] | 99 | |
| 100 | The `Reverted.vm` template will determine the contents of the email related |
| 101 | to a change being reverted. It is a `ChangeEmail`: see `ChangeSubject.vm` and |
| 102 | `ChangeFooter.vm`. |
Martin Fick | 7759a6f | 2011-06-27 10:25:38 -0600 | [diff] [blame] | 103 | |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 104 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 105 | == Mail Variables and Methods |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 106 | |
| 107 | Mail templates can access and display objects currently made available to them |
| 108 | via the velocity context. While the base objects are documented here, it is |
| 109 | possible to call public methods on these objects from templates. Those methods |
| 110 | are not documented here since they could change with every release. As these |
| 111 | templates are meant to be modified only by a qualified sysadmin, it is accepted |
| 112 | that writing templates for Gerrit emails is likely to require some basic |
| 113 | knowledge of the class structure to be useful. Browsing the source code might |
| 114 | be necessary for anything more than a minor formatting change. |
| 115 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 116 | === Warning |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 117 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 118 | Be aware that modifying templates can cause them to fail to parse and therefore |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 119 | not send out the actual email, or worse, calling methods on the available |
| 120 | objects could have internal side effects which would adversely affect the |
| 121 | health of your Gerrit server and/or data. |
| 122 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 123 | === All OutgoingEmails |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 124 | |
| 125 | All outgoing emails have the following variables available to them: |
| 126 | |
| 127 | $email:: |
| 128 | + |
| 129 | A reference to the class constructing the current `OutgoingEmail`. With this |
| 130 | reference it is possible to call any public method on the OutgoingEmail class |
| 131 | or the current child class inherited from it. |
| 132 | |
| 133 | $messageClass:: |
| 134 | + |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 135 | A String containing the messageClass. |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 136 | |
| 137 | $StringUtils:: |
| 138 | + |
| 139 | A reference to the Apache `StringUtils` class. This can be very useful for |
| 140 | formatting strings. |
| 141 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 142 | === Change Emails |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 143 | |
| 144 | All change related emails have the following additional variables available to them: |
| 145 | |
| 146 | $change:: |
| 147 | + |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 148 | A reference to the current `Change` object. |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 149 | |
| 150 | $changeId:: |
| 151 | + |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 152 | Id of the current change (a `Change.Key`). |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 153 | |
| 154 | $coverLetter:: |
| 155 | + |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 156 | The text of the `ChangeMessage`. |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 157 | |
| 158 | $branch:: |
| 159 | + |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 160 | A reference to the branch of this change (a `Branch.NameKey`). |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 161 | |
| 162 | $fromName:: |
| 163 | + |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 164 | The name of the from user. |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 165 | |
| 166 | $projectName:: |
| 167 | + |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 168 | The name of this change's project. |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 169 | |
| 170 | $patchSet:: |
| 171 | + |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 172 | A reference to the current `PatchSet`. |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 173 | |
| 174 | $patchSetInfo:: |
| 175 | + |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 176 | A reference to the current `PatchSetInfo`. |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 177 | |
| 178 | |
Fredrik Luthander | a6bb951 | 2014-03-24 18:59:45 -0700 | [diff] [blame] | 179 | == SEE ALSO |
Martin Fick | b7f3b2d | 2010-07-23 10:23:03 -0600 | [diff] [blame] | 180 | |
| 181 | * link:http://velocity.apache.org/[velocity] |
| 182 | |
| 183 | GERRIT |
| 184 | ------ |
| 185 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 186 | |
| 187 | SEARCHBOX |
| 188 | --------- |