blob: dd7c4c688051859ffc6c20d5119d380d1986fe79 [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`
21to only see changes proposed for the master branch.
Shawn O. Pearce57bec122012-04-26 16:24:12 -070022
David Pursehouse53456c22013-07-08 16:48:14 +090023Notification mails for new changes and new patch sets are not sent to
24the change owner.
25
26Notification mails for comments added on changes are not sent to the user
27who added the comment unless the user has enabled the 'CC Me On Comments I
28Write' option in the user preferences.
29
30
Edwin Kempinef2b6af2014-04-22 11:04:10 +020031[[project]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080032== Project Level Settings
Shawn O. Pearce57bec122012-04-26 16:24:12 -070033
34Project owners and site administrators can configure project level
35notifications, enabling Gerrit Code Review to automatically send
36emails to team mailing lists, or groups of users. Project settings
37are stored inside of the `refs/meta/config` branch of each Git
38repository, and are placed inside of the `project.config` file.
39
40To edit the project level notify settings, ensure the project owner
41has Push permission already granted for the `refs/meta/config`
42branch. Consult link:access-control.html[access controls] for
43details on how access permissions work.
44
45Initialize a temporary Git repository to edit the configuration:
46====
47 mkdir cfg_dir
48 cd cfg_dir
49 git init
50====
51
52Download the existing configuration from Gerrit:
53====
54 git fetch ssh://localhost:29418/project refs/meta/config
55 git checkout FETCH_HEAD
56====
57
58Enable notifications to an email address by adding to
59`project.config`, this can be done using the `git config` command:
60====
61 git config -f project.config --add notify.team.email team-address@example.com
62 git config -f project.config --add notify.team.email paranoid-manager@example.com
63====
64
65Examining the project.config file with any text editor should show
66a new notify section describing the email addresses to deliver to:
67----
68 [notify "team"]
69 email = team-address@example.com
70 email = paranoid-manager@example.com
71----
72
73Each notify section within a single project.config file must have a
74unique name. The section name itself does not matter and may later
75appear in the web UI. Naming a section after the email address or
76group it delivers to is typical. Multiple sections can be specified
77if different filters are needed.
78
79Commit the configuration change, and push it back:
80====
81 git commit -a -m "Notify team-address@example.com of changes"
82 git push ssh://localhost:29418/project HEAD:refs/meta/config
83====
84
85[[notify.name.email]]notify.<name>.email::
86+
87List of email addresses to send matching notifications to. Each
88email address should be placed on its own line.
89+
90Internal groups within Gerrit Code Review can also be named using
91`group NAME` syntax. If this format is used the group's UUID must
92also appear in the corresponding `groups` file. Gerrit will expand
93the group membership and BCC all current users.
94
95[[notify.name.type]]notify.<name>.type::
96+
97Types of notifications to send. If not specified, all notifications
98are sent.
99+
100* `new_changes`: Only newly created changes.
Edwin Kempin11214752013-01-06 19:56:01 +0100101* `new_patchsets`: Only newly created patch sets.
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700102* `all_comments`: Only comments on existing changes.
103* `submitted_changes`: Only changes that have been submitted.
Edwin Kempin3a829612013-01-11 08:10:52 +0100104* `abandoned_changes`: Only changes that have been abandoned.
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700105* `all`: All notifications.
106
107+
108Like email, this variable may be a list of options.
109
Shawn O. Pearceaedcb7e2012-10-25 17:02:50 -0700110[[notify.name.header]]notify.<name>.header::
111+
112Email header used to list the destination. If not set BCC is used.
113Only one value may be specified. To use different headers for each
114address list them in different notify blocks.
115+
116* `to`: The standard To field is used; addresses are visible to all.
117* `cc`: The standard CC field is used; addresses are visible to all.
118* `bcc`: SMTP RCPT TO is used to hide the address.
119
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700120[[notify.name.filter]]notify.<name>.filter::
121+
122link:user-search.html[Change search expression] to match changes that
123should be sent to the emails named in this section. Within a Git-style
124configuration file double quotes around complex operator values may
125need to be escaped, e.g. `filter = branch:\"^(maint|stable)-.*\"`.
126
127When sending email to a bare email address in a notify block, Gerrit
128Code Review ignores read access controls and assumes the administrator
129has set the filtering options correctly. Project owners can implement
130security filtering by adding the `visibleto:groupname` predicate to
131the filter expression, for example:
132
133====
134 [notify "Developers"]
135 email = team-address@example.com
136 filter = visibleto:Developers
137====
138
139When sending email to an internal group, the internal group's read
140access is automatically checked by Gerrit and therefore does not
141need to use the `visibleto:` operator in the filter.
142
143GERRIT
144------
145Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700146
147SEARCHBOX
148---------