Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 1 | = Gerrit Code Review - Email Notifications |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 2 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 3 | == Description |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 4 | |
| 5 | Gerrit can automatically notify users by email when new changes are |
| 6 | uploaded for review, after comments have been posted on a change, |
| 7 | or after the change has been submitted to a branch. |
| 8 | |
Gal Paikin | 1ae8b46 | 2020-07-27 15:50:59 +0300 | [diff] [blame] | 9 | [[recipient-types]] |
| 10 | == Recipient Type |
| 11 | |
| 12 | Those are the available recipient types: |
Edwin Kempin | 0eb303e | 2021-06-15 09:12:02 +0200 | [diff] [blame] | 13 | |
Gal Paikin | 1ae8b46 | 2020-07-27 15:50:59 +0300 | [diff] [blame] | 14 | * `to`: The standard To field is used; addresses are visible to all. |
| 15 | * `cc`: The standard CC field is used; addresses are visible to all. |
| 16 | * `bcc`: SMTP RCPT TO is used to hide the address. |
| 17 | |
Edwin Kempin | ef2b6af | 2014-04-22 11:04:10 +0200 | [diff] [blame] | 18 | [[user]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 19 | == User Level Settings |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 20 | |
| 21 | Individual users can configure email subscriptions by editing |
| 22 | watched projects through Settings > Watched Projects with the web UI. |
| 23 | |
| 24 | Specific projects may be watched, or the special project |
| 25 | `All-Projects` can be watched to watch all projects that |
| 26 | are visible to the user. |
| 27 | |
Edwin Kempin | c2ab715 | 2013-01-07 08:08:51 +0100 | [diff] [blame] | 28 | link:user-search.html[Change search expressions] can be used to filter |
| 29 | change notifications to specific subsets, for example `branch:master` |
Doug Kelly | 85aa001 | 2014-12-11 13:11:30 -0600 | [diff] [blame] | 30 | to only see changes proposed for the master branch. If a filter would |
| 31 | match at the `All-Projects` level as well as a specific project, the |
| 32 | more specific project's notification settings are used. |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 33 | |
David Pursehouse | 53456c2 | 2013-07-08 16:48:14 +0900 | [diff] [blame] | 34 | Notification mails for new changes and new patch sets are not sent to |
| 35 | the change owner. |
| 36 | |
| 37 | Notification mails for comments added on changes are not sent to the user |
Logan Hanks | c88e961 | 2017-09-25 10:17:56 -0700 | [diff] [blame] | 38 | who added the comment unless the user has enabled the 'Every comment' |
| 39 | option in the user preferences. |
David Pursehouse | 53456c2 | 2013-07-08 16:48:14 +0900 | [diff] [blame] | 40 | |
| 41 | |
Edwin Kempin | ef2b6af | 2014-04-22 11:04:10 +0200 | [diff] [blame] | 42 | [[project]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 43 | == Project Level Settings |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 44 | |
| 45 | Project owners and site administrators can configure project level |
| 46 | notifications, enabling Gerrit Code Review to automatically send |
| 47 | emails to team mailing lists, or groups of users. Project settings |
| 48 | are stored inside of the `refs/meta/config` branch of each Git |
| 49 | repository, and are placed inside of the `project.config` file. |
| 50 | |
| 51 | To edit the project level notify settings, ensure the project owner |
| 52 | has Push permission already granted for the `refs/meta/config` |
| 53 | branch. Consult link:access-control.html[access controls] for |
| 54 | details on how access permissions work. |
| 55 | |
| 56 | Initialize a temporary Git repository to edit the configuration: |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 57 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 58 | mkdir cfg_dir |
| 59 | cd cfg_dir |
| 60 | git init |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 61 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 62 | |
| 63 | Download the existing configuration from Gerrit: |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 64 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 65 | git fetch ssh://localhost:29418/project refs/meta/config |
| 66 | git checkout FETCH_HEAD |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 67 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 68 | |
| 69 | Enable notifications to an email address by adding to |
| 70 | `project.config`, this can be done using the `git config` command: |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 71 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 72 | git config -f project.config --add notify.team.email team-address@example.com |
| 73 | git config -f project.config --add notify.team.email paranoid-manager@example.com |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 74 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 75 | |
| 76 | Examining the project.config file with any text editor should show |
| 77 | a new notify section describing the email addresses to deliver to: |
| 78 | ---- |
| 79 | [notify "team"] |
| 80 | email = team-address@example.com |
| 81 | email = paranoid-manager@example.com |
| 82 | ---- |
| 83 | |
| 84 | Each notify section within a single project.config file must have a |
| 85 | unique name. The section name itself does not matter and may later |
| 86 | appear in the web UI. Naming a section after the email address or |
| 87 | group it delivers to is typical. Multiple sections can be specified |
| 88 | if different filters are needed. |
| 89 | |
| 90 | Commit the configuration change, and push it back: |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 91 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 92 | git commit -a -m "Notify team-address@example.com of changes" |
| 93 | git push ssh://localhost:29418/project HEAD:refs/meta/config |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 94 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 95 | |
| 96 | [[notify.name.email]]notify.<name>.email:: |
| 97 | + |
| 98 | List of email addresses to send matching notifications to. Each |
| 99 | email address should be placed on its own line. |
| 100 | + |
| 101 | Internal groups within Gerrit Code Review can also be named using |
| 102 | `group NAME` syntax. If this format is used the group's UUID must |
| 103 | also appear in the corresponding `groups` file. Gerrit will expand |
| 104 | the group membership and BCC all current users. |
| 105 | |
| 106 | [[notify.name.type]]notify.<name>.type:: |
| 107 | + |
| 108 | Types of notifications to send. If not specified, all notifications |
| 109 | are sent. |
| 110 | + |
| 111 | * `new_changes`: Only newly created changes. |
Edwin Kempin | 1121475 | 2013-01-06 19:56:01 +0100 | [diff] [blame] | 112 | * `new_patchsets`: Only newly created patch sets. |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 113 | * `all_comments`: Only comments on existing changes. |
| 114 | * `submitted_changes`: Only changes that have been submitted. |
Edwin Kempin | 3a82961 | 2013-01-11 08:10:52 +0100 | [diff] [blame] | 115 | * `abandoned_changes`: Only changes that have been abandoned. |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 116 | * `all`: All notifications. |
| 117 | |
| 118 | + |
| 119 | Like email, this variable may be a list of options. |
| 120 | |
Shawn O. Pearce | aedcb7e | 2012-10-25 17:02:50 -0700 | [diff] [blame] | 121 | [[notify.name.header]]notify.<name>.header:: |
| 122 | + |
| 123 | Email header used to list the destination. If not set BCC is used. |
| 124 | Only one value may be specified. To use different headers for each |
| 125 | address list them in different notify blocks. |
Gal Paikin | 1ae8b46 | 2020-07-27 15:50:59 +0300 | [diff] [blame] | 126 | |
| 127 | The possible options are the link:#recipient-types[recipient types]. |
Shawn O. Pearce | aedcb7e | 2012-10-25 17:02:50 -0700 | [diff] [blame] | 128 | |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 129 | [[notify.name.filter]]notify.<name>.filter:: |
| 130 | + |
| 131 | link:user-search.html[Change search expression] to match changes that |
| 132 | should be sent to the emails named in this section. Within a Git-style |
| 133 | configuration file double quotes around complex operator values may |
| 134 | need to be escaped, e.g. `filter = branch:\"^(maint|stable)-.*\"`. |
Patrick Hiesel | 64a862f | 2019-12-10 14:21:55 +0100 | [diff] [blame] | 135 | Single quotes are illegal and must be omitted. |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 136 | |
| 137 | When sending email to a bare email address in a notify block, Gerrit |
| 138 | Code Review ignores read access controls and assumes the administrator |
| 139 | has set the filtering options correctly. Project owners can implement |
| 140 | security filtering by adding the `visibleto:groupname` predicate to |
| 141 | the filter expression, for example: |
| 142 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 143 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 144 | [notify "Developers"] |
| 145 | email = team-address@example.com |
| 146 | filter = visibleto:Developers |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 147 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 148 | |
| 149 | When sending email to an internal group, the internal group's read |
| 150 | access is automatically checked by Gerrit and therefore does not |
| 151 | need to use the `visibleto:` operator in the filter. |
| 152 | |
Wyatt Allen | 12a3602 | 2016-11-28 11:28:10 -0800 | [diff] [blame] | 153 | [[footers]] |
| 154 | == Email Footers |
| 155 | |
| 156 | Notification emails related to changes include metadata about the change |
| 157 | to support writing mail filters. This metadata is included in the form |
| 158 | of footers in the message content. For HTML emails, these footers are |
| 159 | hidden, but they can be examined by viewing the HTML source of messages. |
| 160 | |
| 161 | In this way users may apply filters and rules to their incoming Gerrit |
| 162 | notifications using the values of these footers. For example a Gmail |
| 163 | filter to find emails regarding reviews that you are a reviewer of might |
| 164 | take the following form. |
| 165 | |
| 166 | ---- |
| 167 | "Gerrit-Reviewer: Your Name <your.email@example.com>" |
| 168 | ---- |
| 169 | |
| 170 | [[Gerrit-MessageType]]Gerrit-MessageType:: |
| 171 | |
| 172 | The message type footer states the type of the message and will take one |
| 173 | of the following values. |
| 174 | |
| 175 | * abandon |
| 176 | * comment |
| 177 | * deleteReviewer |
| 178 | * deleteVote |
| 179 | * merged |
| 180 | * newchange |
| 181 | * newpatchset |
| 182 | * restore |
| 183 | * revert |
| 184 | * setassignee |
| 185 | |
| 186 | [[Gerrit-Change-Id]]Gerrit-Change-Id:: |
| 187 | |
| 188 | The change ID footer states the ID of the change, such as |
| 189 | `I3443af49fcdc16ca941ee7cf2b5e33c1106f3b1d`. |
| 190 | |
| 191 | [[Gerrit-Change-Number]]Gerrit-Change-Number:: |
| 192 | |
| 193 | The change number footer states the numeric ID of the change, for |
| 194 | example `92191`. |
| 195 | |
| 196 | [[Gerrit-PatchSet]]Gerrit-PatchSet:: |
| 197 | |
| 198 | The patch set footer states the number of the patch set that the email |
| 199 | relates to. For example, a notification email for a vote being set on |
| 200 | the seventh patch set will take a value of `7`. |
| 201 | |
| 202 | [[Gerrit-Owner]]Gerrit-Owner:: |
| 203 | |
| 204 | The owner footer states the name and email address of the change's |
| 205 | owner. For example, `Owner Name <owner@example.com>`. |
| 206 | |
| 207 | [[Gerrit-Reviewer]]Gerrit-Reviewer:: |
| 208 | |
| 209 | The reviewer footers list the names and email addresses of the change's |
| 210 | reviewrs. One footer is included for each reviewer. For example, if a |
| 211 | change has two reviewers, the footers might include: |
| 212 | |
| 213 | ---- |
| 214 | Gerrit-Reviewer: Reviewer One <one@example.com> |
| 215 | Gerrit-Reviewer: Reviewer Two <two@example.com> |
| 216 | ---- |
| 217 | |
| 218 | [[Gerrit-CC]]Gerrit-CC:: |
| 219 | |
| 220 | The CC footers list the names and email addresses of those who have been |
| 221 | CC'd on the change. One footer is included for each reviewer. For |
| 222 | example, if a change CCs two users, the footers might include: |
| 223 | |
| 224 | ---- |
| 225 | Gerrit-CC: User One <one@example.com> |
| 226 | Gerrit-CC: User Two <two@example.com> |
| 227 | ---- |
| 228 | |
| 229 | [[Gerrit-Project]]Gerrit-Project:: |
| 230 | |
| 231 | The project footer states the project to which the change belongs. |
| 232 | |
| 233 | [[Gerrit-Branch]]Gerrit-Branch:: |
| 234 | |
| 235 | The branch footer states the abbreviated name of the branch that the |
| 236 | change targets. |
| 237 | |
| 238 | [[Gerrit-Comment-Date]]Gerrit-Comment-Date:: |
| 239 | |
| 240 | In comment emails, the comment date footer states the date that the |
| 241 | comment was posted. |
| 242 | |
| 243 | [[Gerrit-HasComments]]Gerrit-HasComments:: |
| 244 | |
| 245 | In comment emails, the has-comments footer states whether inline |
| 246 | comments had been posted in that notification using "Yes" or "No", for |
| 247 | example `Gerrit-HasComments: Yes`. |
| 248 | |
| 249 | [[Gerrit-HasLabels]]Gerrit-HasLabels:: |
| 250 | |
| 251 | In comment emails, the has-labels footer states whether label votes had |
| 252 | been posted in that notification using "Yes" or "No", for |
| 253 | example `Gerrit-HasLabels: No`. |
| 254 | |
Wyatt Allen | d8c4931 | 2017-10-03 10:08:15 +0100 | [diff] [blame] | 255 | [[Gerrit-Comment-In-Reply-To]]Gerrit-Comment-In-Reply-To:: |
| 256 | |
| 257 | In comment emails, a comment-in-reply-to footer is present for each |
| 258 | account who has a comment that is replied-to in that set of comments. |
| 259 | For example, to apply a filter to Gerrit messages in which your own diff |
| 260 | comments are responded to, you might search for the following: |
| 261 | |
| 262 | ---- |
| 263 | Gerrit-Comment-In-Reply-To: User Name <user@example.com> |
| 264 | ---- |
| 265 | |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 266 | GERRIT |
| 267 | ------ |
| 268 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 269 | |
| 270 | SEARCHBOX |
| 271 | --------- |