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