blob: 3c922ed716a93926bcbdd62b80db4cd7455f19f7 [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001= Gerrit Code Review - Email Notifications
Shawn O. Pearce57bec122012-04-26 16:24:12 -07002
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08003== Description
Shawn O. Pearce57bec122012-04-26 16:24:12 -07004
5Gerrit can automatically notify users by email when new changes are
6uploaded for review, after comments have been posted on a change,
7or after the change has been submitted to a branch.
8
Edwin Kempinef2b6af2014-04-22 11:04:10 +02009[[user]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080010== User Level Settings
Shawn O. Pearce57bec122012-04-26 16:24:12 -070011
12Individual users can configure email subscriptions by editing
13watched projects through Settings > Watched Projects with the web UI.
14
15Specific projects may be watched, or the special project
16`All-Projects` can be watched to watch all projects that
17are visible to the user.
18
Edwin Kempinc2ab7152013-01-07 08:08:51 +010019link:user-search.html[Change search expressions] can be used to filter
20change notifications to specific subsets, for example `branch:master`
Doug Kelly85aa0012014-12-11 13:11:30 -060021to only see changes proposed for the master branch. If a filter would
22match at the `All-Projects` level as well as a specific project, the
23more specific project's notification settings are used.
Shawn O. Pearce57bec122012-04-26 16:24:12 -070024
David Pursehouse53456c22013-07-08 16:48:14 +090025Notification mails for new changes and new patch sets are not sent to
26the change owner.
27
28Notification mails for comments added on changes are not sent to the user
Logan Hanksc88e9612017-09-25 10:17:56 -070029who added the comment unless the user has enabled the 'Every comment'
30option in the user preferences.
David Pursehouse53456c22013-07-08 16:48:14 +090031
32
Edwin Kempinef2b6af2014-04-22 11:04:10 +020033[[project]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080034== Project Level Settings
Shawn O. Pearce57bec122012-04-26 16:24:12 -070035
36Project owners and site administrators can configure project level
37notifications, enabling Gerrit Code Review to automatically send
38emails to team mailing lists, or groups of users. Project settings
39are stored inside of the `refs/meta/config` branch of each Git
40repository, and are placed inside of the `project.config` file.
41
42To edit the project level notify settings, ensure the project owner
43has Push permission already granted for the `refs/meta/config`
44branch. Consult link:access-control.html[access controls] for
45details on how access permissions work.
46
47Initialize a temporary Git repository to edit the configuration:
Michael Ochmannb99feab2016-07-06 14:10:22 +020048----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070049 mkdir cfg_dir
50 cd cfg_dir
51 git init
Michael Ochmannb99feab2016-07-06 14:10:22 +020052----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070053
54Download the existing configuration from Gerrit:
Michael Ochmannb99feab2016-07-06 14:10:22 +020055----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070056 git fetch ssh://localhost:29418/project refs/meta/config
57 git checkout FETCH_HEAD
Michael Ochmannb99feab2016-07-06 14:10:22 +020058----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070059
60Enable notifications to an email address by adding to
61`project.config`, this can be done using the `git config` command:
Michael Ochmannb99feab2016-07-06 14:10:22 +020062----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070063 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 Ochmannb99feab2016-07-06 14:10:22 +020065----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070066
67Examining the project.config file with any text editor should show
68a 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
75Each notify section within a single project.config file must have a
76unique name. The section name itself does not matter and may later
77appear in the web UI. Naming a section after the email address or
78group it delivers to is typical. Multiple sections can be specified
79if different filters are needed.
80
81Commit the configuration change, and push it back:
Michael Ochmannb99feab2016-07-06 14:10:22 +020082----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070083 git commit -a -m "Notify team-address@example.com of changes"
84 git push ssh://localhost:29418/project HEAD:refs/meta/config
Michael Ochmannb99feab2016-07-06 14:10:22 +020085----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070086
87[[notify.name.email]]notify.<name>.email::
88+
89List of email addresses to send matching notifications to. Each
90email address should be placed on its own line.
91+
92Internal groups within Gerrit Code Review can also be named using
93`group NAME` syntax. If this format is used the group's UUID must
94also appear in the corresponding `groups` file. Gerrit will expand
95the group membership and BCC all current users.
96
97[[notify.name.type]]notify.<name>.type::
98+
99Types of notifications to send. If not specified, all notifications
100are sent.
101+
102* `new_changes`: Only newly created changes.
Edwin Kempin11214752013-01-06 19:56:01 +0100103* `new_patchsets`: Only newly created patch sets.
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700104* `all_comments`: Only comments on existing changes.
105* `submitted_changes`: Only changes that have been submitted.
Edwin Kempin3a829612013-01-11 08:10:52 +0100106* `abandoned_changes`: Only changes that have been abandoned.
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700107* `all`: All notifications.
108
109+
110Like email, this variable may be a list of options.
111
Shawn O. Pearceaedcb7e2012-10-25 17:02:50 -0700112[[notify.name.header]]notify.<name>.header::
113+
114Email header used to list the destination. If not set BCC is used.
115Only one value may be specified. To use different headers for each
116address 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. Pearce57bec122012-04-26 16:24:12 -0700122[[notify.name.filter]]notify.<name>.filter::
123+
124link:user-search.html[Change search expression] to match changes that
125should be sent to the emails named in this section. Within a Git-style
126configuration file double quotes around complex operator values may
127need to be escaped, e.g. `filter = branch:\"^(maint|stable)-.*\"`.
128
129When sending email to a bare email address in a notify block, Gerrit
130Code Review ignores read access controls and assumes the administrator
131has set the filtering options correctly. Project owners can implement
132security filtering by adding the `visibleto:groupname` predicate to
133the filter expression, for example:
134
Michael Ochmannb99feab2016-07-06 14:10:22 +0200135----
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700136 [notify "Developers"]
137 email = team-address@example.com
138 filter = visibleto:Developers
Michael Ochmannb99feab2016-07-06 14:10:22 +0200139----
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700140
141When sending email to an internal group, the internal group's read
142access is automatically checked by Gerrit and therefore does not
143need to use the `visibleto:` operator in the filter.
144
Wyatt Allen12a36022016-11-28 11:28:10 -0800145[[footers]]
146== Email Footers
147
148Notification emails related to changes include metadata about the change
149to support writing mail filters. This metadata is included in the form
150of footers in the message content. For HTML emails, these footers are
151hidden, but they can be examined by viewing the HTML source of messages.
152
153In this way users may apply filters and rules to their incoming Gerrit
154notifications using the values of these footers. For example a Gmail
155filter to find emails regarding reviews that you are a reviewer of might
156take the following form.
157
158----
159 "Gerrit-Reviewer: Your Name <your.email@example.com>"
160----
161
162[[Gerrit-MessageType]]Gerrit-MessageType::
163
164The message type footer states the type of the message and will take one
165of 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
180The change ID footer states the ID of the change, such as
181`I3443af49fcdc16ca941ee7cf2b5e33c1106f3b1d`.
182
183[[Gerrit-Change-Number]]Gerrit-Change-Number::
184
185The change number footer states the numeric ID of the change, for
186example `92191`.
187
188[[Gerrit-PatchSet]]Gerrit-PatchSet::
189
190The patch set footer states the number of the patch set that the email
191relates to. For example, a notification email for a vote being set on
192the seventh patch set will take a value of `7`.
193
194[[Gerrit-Owner]]Gerrit-Owner::
195
196The owner footer states the name and email address of the change's
197owner. For example, `Owner Name <owner@example.com>`.
198
199[[Gerrit-Reviewer]]Gerrit-Reviewer::
200
201The reviewer footers list the names and email addresses of the change's
202reviewrs. One footer is included for each reviewer. For example, if a
203change 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
212The CC footers list the names and email addresses of those who have been
213CC'd on the change. One footer is included for each reviewer. For
214example, 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
223The project footer states the project to which the change belongs.
224
225[[Gerrit-Branch]]Gerrit-Branch::
226
227The branch footer states the abbreviated name of the branch that the
228change targets.
229
230[[Gerrit-Comment-Date]]Gerrit-Comment-Date::
231
232In comment emails, the comment date footer states the date that the
233comment was posted.
234
235[[Gerrit-HasComments]]Gerrit-HasComments::
236
237In comment emails, the has-comments footer states whether inline
238comments had been posted in that notification using "Yes" or "No", for
239example `Gerrit-HasComments: Yes`.
240
241[[Gerrit-HasLabels]]Gerrit-HasLabels::
242
243In comment emails, the has-labels footer states whether label votes had
244been posted in that notification using "Yes" or "No", for
245example `Gerrit-HasLabels: No`.
246
Wyatt Allend8c49312017-10-03 10:08:15 +0100247[[Gerrit-Comment-In-Reply-To]]Gerrit-Comment-In-Reply-To::
248
249In comment emails, a comment-in-reply-to footer is present for each
250account who has a comment that is replied-to in that set of comments.
251For example, to apply a filter to Gerrit messages in which your own diff
252comments 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. Pearce57bec122012-04-26 16:24:12 -0700258GERRIT
259------
260Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700261
262SEARCHBOX
263---------