blob: 128bae65f4b21fc8e5e9946feae7261955e23ba8 [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
Gal Paikin1ae8b462020-07-27 15:50:59 +03009[[recipient-types]]
10== Recipient Type
11
12Those are the available recipient types:
Edwin Kempin0eb303e2021-06-15 09:12:02 +020013
Gal Paikin1ae8b462020-07-27 15:50:59 +030014* `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 Kempinef2b6af2014-04-22 11:04:10 +020018[[user]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080019== User Level Settings
Shawn O. Pearce57bec122012-04-26 16:24:12 -070020
21Individual users can configure email subscriptions by editing
22watched projects through Settings > Watched Projects with the web UI.
23
24Specific projects may be watched, or the special project
25`All-Projects` can be watched to watch all projects that
26are visible to the user.
27
Edwin Kempinc2ab7152013-01-07 08:08:51 +010028link:user-search.html[Change search expressions] can be used to filter
29change notifications to specific subsets, for example `branch:master`
Doug Kelly85aa0012014-12-11 13:11:30 -060030to only see changes proposed for the master branch. If a filter would
31match at the `All-Projects` level as well as a specific project, the
32more specific project's notification settings are used.
Shawn O. Pearce57bec122012-04-26 16:24:12 -070033
David Pursehouse53456c22013-07-08 16:48:14 +090034Notification mails for new changes and new patch sets are not sent to
35the change owner.
36
37Notification mails for comments added on changes are not sent to the user
Logan Hanksc88e9612017-09-25 10:17:56 -070038who added the comment unless the user has enabled the 'Every comment'
39option in the user preferences.
David Pursehouse53456c22013-07-08 16:48:14 +090040
41
Edwin Kempinef2b6af2014-04-22 11:04:10 +020042[[project]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080043== Project Level Settings
Shawn O. Pearce57bec122012-04-26 16:24:12 -070044
45Project owners and site administrators can configure project level
46notifications, enabling Gerrit Code Review to automatically send
47emails to team mailing lists, or groups of users. Project settings
48are stored inside of the `refs/meta/config` branch of each Git
49repository, and are placed inside of the `project.config` file.
50
51To edit the project level notify settings, ensure the project owner
52has Push permission already granted for the `refs/meta/config`
53branch. Consult link:access-control.html[access controls] for
54details on how access permissions work.
55
56Initialize a temporary Git repository to edit the configuration:
Michael Ochmannb99feab2016-07-06 14:10:22 +020057----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070058 mkdir cfg_dir
59 cd cfg_dir
60 git init
Michael Ochmannb99feab2016-07-06 14:10:22 +020061----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070062
63Download the existing configuration from Gerrit:
Michael Ochmannb99feab2016-07-06 14:10:22 +020064----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070065 git fetch ssh://localhost:29418/project refs/meta/config
66 git checkout FETCH_HEAD
Michael Ochmannb99feab2016-07-06 14:10:22 +020067----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070068
69Enable notifications to an email address by adding to
70`project.config`, this can be done using the `git config` command:
Michael Ochmannb99feab2016-07-06 14:10:22 +020071----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070072 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 Ochmannb99feab2016-07-06 14:10:22 +020074----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070075
76Examining the project.config file with any text editor should show
77a 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
84Each notify section within a single project.config file must have a
85unique name. The section name itself does not matter and may later
86appear in the web UI. Naming a section after the email address or
87group it delivers to is typical. Multiple sections can be specified
88if different filters are needed.
89
90Commit the configuration change, and push it back:
Michael Ochmannb99feab2016-07-06 14:10:22 +020091----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070092 git commit -a -m "Notify team-address@example.com of changes"
93 git push ssh://localhost:29418/project HEAD:refs/meta/config
Michael Ochmannb99feab2016-07-06 14:10:22 +020094----
Shawn O. Pearce57bec122012-04-26 16:24:12 -070095
96[[notify.name.email]]notify.<name>.email::
97+
98List of email addresses to send matching notifications to. Each
99email address should be placed on its own line.
100+
101Internal groups within Gerrit Code Review can also be named using
102`group NAME` syntax. If this format is used the group's UUID must
103also appear in the corresponding `groups` file. Gerrit will expand
104the group membership and BCC all current users.
105
106[[notify.name.type]]notify.<name>.type::
107+
108Types of notifications to send. If not specified, all notifications
109are sent.
110+
111* `new_changes`: Only newly created changes.
Edwin Kempin11214752013-01-06 19:56:01 +0100112* `new_patchsets`: Only newly created patch sets.
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700113* `all_comments`: Only comments on existing changes.
114* `submitted_changes`: Only changes that have been submitted.
Edwin Kempin3a829612013-01-11 08:10:52 +0100115* `abandoned_changes`: Only changes that have been abandoned.
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700116* `all`: All notifications.
117
118+
119Like email, this variable may be a list of options.
120
Shawn O. Pearceaedcb7e2012-10-25 17:02:50 -0700121[[notify.name.header]]notify.<name>.header::
122+
123Email header used to list the destination. If not set BCC is used.
124Only one value may be specified. To use different headers for each
125address list them in different notify blocks.
Gal Paikin1ae8b462020-07-27 15:50:59 +0300126
127The possible options are the link:#recipient-types[recipient types].
Shawn O. Pearceaedcb7e2012-10-25 17:02:50 -0700128
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700129[[notify.name.filter]]notify.<name>.filter::
130+
131link:user-search.html[Change search expression] to match changes that
132should be sent to the emails named in this section. Within a Git-style
133configuration file double quotes around complex operator values may
134need to be escaped, e.g. `filter = branch:\"^(maint|stable)-.*\"`.
Patrick Hiesel64a862f2019-12-10 14:21:55 +0100135Single quotes are illegal and must be omitted.
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700136
137When sending email to a bare email address in a notify block, Gerrit
138Code Review ignores read access controls and assumes the administrator
139has set the filtering options correctly. Project owners can implement
140security filtering by adding the `visibleto:groupname` predicate to
141the filter expression, for example:
142
Michael Ochmannb99feab2016-07-06 14:10:22 +0200143----
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700144 [notify "Developers"]
145 email = team-address@example.com
146 filter = visibleto:Developers
Michael Ochmannb99feab2016-07-06 14:10:22 +0200147----
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700148
149When sending email to an internal group, the internal group's read
150access is automatically checked by Gerrit and therefore does not
151need to use the `visibleto:` operator in the filter.
152
Wyatt Allen12a36022016-11-28 11:28:10 -0800153[[footers]]
154== Email Footers
155
156Notification emails related to changes include metadata about the change
157to support writing mail filters. This metadata is included in the form
158of footers in the message content. For HTML emails, these footers are
159hidden, but they can be examined by viewing the HTML source of messages.
160
161In this way users may apply filters and rules to their incoming Gerrit
162notifications using the values of these footers. For example a Gmail
163filter to find emails regarding reviews that you are a reviewer of might
164take the following form.
165
166----
167 "Gerrit-Reviewer: Your Name <your.email@example.com>"
168----
169
170[[Gerrit-MessageType]]Gerrit-MessageType::
171
172The message type footer states the type of the message and will take one
173of 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
188The change ID footer states the ID of the change, such as
189`I3443af49fcdc16ca941ee7cf2b5e33c1106f3b1d`.
190
191[[Gerrit-Change-Number]]Gerrit-Change-Number::
192
193The change number footer states the numeric ID of the change, for
194example `92191`.
195
196[[Gerrit-PatchSet]]Gerrit-PatchSet::
197
198The patch set footer states the number of the patch set that the email
199relates to. For example, a notification email for a vote being set on
200the seventh patch set will take a value of `7`.
201
202[[Gerrit-Owner]]Gerrit-Owner::
203
204The owner footer states the name and email address of the change's
205owner. For example, `Owner Name <owner@example.com>`.
206
207[[Gerrit-Reviewer]]Gerrit-Reviewer::
208
209The reviewer footers list the names and email addresses of the change's
210reviewrs. One footer is included for each reviewer. For example, if a
211change 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
220The CC footers list the names and email addresses of those who have been
221CC'd on the change. One footer is included for each reviewer. For
222example, 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
231The project footer states the project to which the change belongs.
232
233[[Gerrit-Branch]]Gerrit-Branch::
234
235The branch footer states the abbreviated name of the branch that the
236change targets.
237
238[[Gerrit-Comment-Date]]Gerrit-Comment-Date::
239
240In comment emails, the comment date footer states the date that the
241comment was posted.
242
243[[Gerrit-HasComments]]Gerrit-HasComments::
244
245In comment emails, the has-comments footer states whether inline
246comments had been posted in that notification using "Yes" or "No", for
247example `Gerrit-HasComments: Yes`.
248
249[[Gerrit-HasLabels]]Gerrit-HasLabels::
250
251In comment emails, the has-labels footer states whether label votes had
252been posted in that notification using "Yes" or "No", for
253example `Gerrit-HasLabels: No`.
254
Wyatt Allend8c49312017-10-03 10:08:15 +0100255[[Gerrit-Comment-In-Reply-To]]Gerrit-Comment-In-Reply-To::
256
257In comment emails, a comment-in-reply-to footer is present for each
258account who has a comment that is replied-to in that set of comments.
259For example, to apply a filter to Gerrit messages in which your own diff
260comments 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. Pearce57bec122012-04-26 16:24:12 -0700266GERRIT
267------
268Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700269
270SEARCHBOX
271---------