blob: 4dc4880b7c83ab13b6406df24828235660b04d8a [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
29who added the comment unless the user has enabled the 'CC Me On Comments I
30Write' option in the user preferences.
31
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
145GERRIT
146------
147Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700148
149SEARCHBOX
150---------