blob: fc5e49bed5247c2246f79437ea780fba661b2278 [file] [log] [blame]
Shawn O. Pearce57bec122012-04-26 16:24:12 -07001Gerrit Code Review - Email Notifications
2========================================
3
4Description
5-----------
6
7Gerrit can automatically notify users by email when new changes are
8uploaded for review, after comments have been posted on a change,
9or after the change has been submitted to a branch.
10
11User Level Settings
12-------------------
13
14Individual users can configure email subscriptions by editing
15watched projects through Settings > Watched Projects with the web UI.
16
17Specific projects may be watched, or the special project
18`All-Projects` can be watched to watch all projects that
19are visible to the user.
20
21Change search expressions can be used to filter change notifications
22to specific subsets, for example `branch:master` to only see changes
23proposed for the master branch.
24
25Project Level Settings
26----------------------
27
28Project owners and site administrators can configure project level
29notifications, enabling Gerrit Code Review to automatically send
30emails to team mailing lists, or groups of users. Project settings
31are stored inside of the `refs/meta/config` branch of each Git
32repository, and are placed inside of the `project.config` file.
33
34To edit the project level notify settings, ensure the project owner
35has Push permission already granted for the `refs/meta/config`
36branch. Consult link:access-control.html[access controls] for
37details on how access permissions work.
38
39Initialize a temporary Git repository to edit the configuration:
40====
41 mkdir cfg_dir
42 cd cfg_dir
43 git init
44====
45
46Download the existing configuration from Gerrit:
47====
48 git fetch ssh://localhost:29418/project refs/meta/config
49 git checkout FETCH_HEAD
50====
51
52Enable notifications to an email address by adding to
53`project.config`, this can be done using the `git config` command:
54====
55 git config -f project.config --add notify.team.email team-address@example.com
56 git config -f project.config --add notify.team.email paranoid-manager@example.com
57====
58
59Examining the project.config file with any text editor should show
60a new notify section describing the email addresses to deliver to:
61----
62 [notify "team"]
63 email = team-address@example.com
64 email = paranoid-manager@example.com
65----
66
67Each notify section within a single project.config file must have a
68unique name. The section name itself does not matter and may later
69appear in the web UI. Naming a section after the email address or
70group it delivers to is typical. Multiple sections can be specified
71if different filters are needed.
72
73Commit the configuration change, and push it back:
74====
75 git commit -a -m "Notify team-address@example.com of changes"
76 git push ssh://localhost:29418/project HEAD:refs/meta/config
77====
78
79[[notify.name.email]]notify.<name>.email::
80+
81List of email addresses to send matching notifications to. Each
82email address should be placed on its own line.
83+
84Internal groups within Gerrit Code Review can also be named using
85`group NAME` syntax. If this format is used the group's UUID must
86also appear in the corresponding `groups` file. Gerrit will expand
87the group membership and BCC all current users.
88
89[[notify.name.type]]notify.<name>.type::
90+
91Types of notifications to send. If not specified, all notifications
92are sent.
93+
94* `new_changes`: Only newly created changes.
95* `all_comments`: Only comments on existing changes.
96* `submitted_changes`: Only changes that have been submitted.
97* `all`: All notifications.
98
99+
100Like email, this variable may be a list of options.
101
Shawn O. Pearceaedcb7e2012-10-25 17:02:50 -0700102[[notify.name.header]]notify.<name>.header::
103+
104Email header used to list the destination. If not set BCC is used.
105Only one value may be specified. To use different headers for each
106address list them in different notify blocks.
107+
108* `to`: The standard To field is used; addresses are visible to all.
109* `cc`: The standard CC field is used; addresses are visible to all.
110* `bcc`: SMTP RCPT TO is used to hide the address.
111
Shawn O. Pearce57bec122012-04-26 16:24:12 -0700112[[notify.name.filter]]notify.<name>.filter::
113+
114link:user-search.html[Change search expression] to match changes that
115should be sent to the emails named in this section. Within a Git-style
116configuration file double quotes around complex operator values may
117need to be escaped, e.g. `filter = branch:\"^(maint|stable)-.*\"`.
118
119When sending email to a bare email address in a notify block, Gerrit
120Code Review ignores read access controls and assumes the administrator
121has set the filtering options correctly. Project owners can implement
122security filtering by adding the `visibleto:groupname` predicate to
123the filter expression, for example:
124
125====
126 [notify "Developers"]
127 email = team-address@example.com
128 filter = visibleto:Developers
129====
130
131When sending email to an internal group, the internal group's read
132access is automatically checked by Gerrit and therefore does not
133need to use the `visibleto:` operator in the filter.
134
135GERRIT
136------
137Part of link:index.html[Gerrit Code Review]