Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 1 | = Gerrit Code Review - Email Notifications |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 2 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 3 | == Description |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 4 | |
| 5 | Gerrit can automatically notify users by email when new changes are |
| 6 | uploaded for review, after comments have been posted on a change, |
| 7 | or after the change has been submitted to a branch. |
| 8 | |
Edwin Kempin | ef2b6af | 2014-04-22 11:04:10 +0200 | [diff] [blame] | 9 | [[user]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 10 | == User Level Settings |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 11 | |
| 12 | Individual users can configure email subscriptions by editing |
| 13 | watched projects through Settings > Watched Projects with the web UI. |
| 14 | |
| 15 | Specific projects may be watched, or the special project |
| 16 | `All-Projects` can be watched to watch all projects that |
| 17 | are visible to the user. |
| 18 | |
Edwin Kempin | c2ab715 | 2013-01-07 08:08:51 +0100 | [diff] [blame] | 19 | link:user-search.html[Change search expressions] can be used to filter |
| 20 | change notifications to specific subsets, for example `branch:master` |
Doug Kelly | 85aa001 | 2014-12-11 13:11:30 -0600 | [diff] [blame] | 21 | to only see changes proposed for the master branch. If a filter would |
| 22 | match at the `All-Projects` level as well as a specific project, the |
| 23 | more specific project's notification settings are used. |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 24 | |
David Pursehouse | 53456c2 | 2013-07-08 16:48:14 +0900 | [diff] [blame] | 25 | Notification mails for new changes and new patch sets are not sent to |
| 26 | the change owner. |
| 27 | |
| 28 | Notification mails for comments added on changes are not sent to the user |
| 29 | who added the comment unless the user has enabled the 'CC Me On Comments I |
| 30 | Write' option in the user preferences. |
| 31 | |
| 32 | |
Edwin Kempin | ef2b6af | 2014-04-22 11:04:10 +0200 | [diff] [blame] | 33 | [[project]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 34 | == Project Level Settings |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 35 | |
| 36 | Project owners and site administrators can configure project level |
| 37 | notifications, enabling Gerrit Code Review to automatically send |
| 38 | emails to team mailing lists, or groups of users. Project settings |
| 39 | are stored inside of the `refs/meta/config` branch of each Git |
| 40 | repository, and are placed inside of the `project.config` file. |
| 41 | |
| 42 | To edit the project level notify settings, ensure the project owner |
| 43 | has Push permission already granted for the `refs/meta/config` |
| 44 | branch. Consult link:access-control.html[access controls] for |
| 45 | details on how access permissions work. |
| 46 | |
| 47 | Initialize a temporary Git repository to edit the configuration: |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 48 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 49 | mkdir cfg_dir |
| 50 | cd cfg_dir |
| 51 | git init |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 52 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 53 | |
| 54 | Download the existing configuration from Gerrit: |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 55 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 56 | git fetch ssh://localhost:29418/project refs/meta/config |
| 57 | git checkout FETCH_HEAD |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 58 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 59 | |
| 60 | Enable notifications to an email address by adding to |
| 61 | `project.config`, this can be done using the `git config` command: |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 62 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 63 | 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 Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 65 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 66 | |
| 67 | Examining the project.config file with any text editor should show |
| 68 | a 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 | |
| 75 | Each notify section within a single project.config file must have a |
| 76 | unique name. The section name itself does not matter and may later |
| 77 | appear in the web UI. Naming a section after the email address or |
| 78 | group it delivers to is typical. Multiple sections can be specified |
| 79 | if different filters are needed. |
| 80 | |
| 81 | Commit the configuration change, and push it back: |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 82 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 83 | git commit -a -m "Notify team-address@example.com of changes" |
| 84 | git push ssh://localhost:29418/project HEAD:refs/meta/config |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 85 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 86 | |
| 87 | [[notify.name.email]]notify.<name>.email:: |
| 88 | + |
| 89 | List of email addresses to send matching notifications to. Each |
| 90 | email address should be placed on its own line. |
| 91 | + |
| 92 | Internal groups within Gerrit Code Review can also be named using |
| 93 | `group NAME` syntax. If this format is used the group's UUID must |
| 94 | also appear in the corresponding `groups` file. Gerrit will expand |
| 95 | the group membership and BCC all current users. |
| 96 | |
| 97 | [[notify.name.type]]notify.<name>.type:: |
| 98 | + |
| 99 | Types of notifications to send. If not specified, all notifications |
| 100 | are sent. |
| 101 | + |
| 102 | * `new_changes`: Only newly created changes. |
Edwin Kempin | 1121475 | 2013-01-06 19:56:01 +0100 | [diff] [blame] | 103 | * `new_patchsets`: Only newly created patch sets. |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 104 | * `all_comments`: Only comments on existing changes. |
| 105 | * `submitted_changes`: Only changes that have been submitted. |
Edwin Kempin | 3a82961 | 2013-01-11 08:10:52 +0100 | [diff] [blame] | 106 | * `abandoned_changes`: Only changes that have been abandoned. |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 107 | * `all`: All notifications. |
| 108 | |
| 109 | + |
| 110 | Like email, this variable may be a list of options. |
| 111 | |
Shawn O. Pearce | aedcb7e | 2012-10-25 17:02:50 -0700 | [diff] [blame] | 112 | [[notify.name.header]]notify.<name>.header:: |
| 113 | + |
| 114 | Email header used to list the destination. If not set BCC is used. |
| 115 | Only one value may be specified. To use different headers for each |
| 116 | address 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. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 122 | [[notify.name.filter]]notify.<name>.filter:: |
| 123 | + |
| 124 | link:user-search.html[Change search expression] to match changes that |
| 125 | should be sent to the emails named in this section. Within a Git-style |
| 126 | configuration file double quotes around complex operator values may |
| 127 | need to be escaped, e.g. `filter = branch:\"^(maint|stable)-.*\"`. |
| 128 | |
| 129 | When sending email to a bare email address in a notify block, Gerrit |
| 130 | Code Review ignores read access controls and assumes the administrator |
| 131 | has set the filtering options correctly. Project owners can implement |
| 132 | security filtering by adding the `visibleto:groupname` predicate to |
| 133 | the filter expression, for example: |
| 134 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 135 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 136 | [notify "Developers"] |
| 137 | email = team-address@example.com |
| 138 | filter = visibleto:Developers |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 139 | ---- |
Shawn O. Pearce | 57bec12 | 2012-04-26 16:24:12 -0700 | [diff] [blame] | 140 | |
| 141 | When sending email to an internal group, the internal group's read |
| 142 | access is automatically checked by Gerrit and therefore does not |
| 143 | need to use the `visibleto:` operator in the filter. |
| 144 | |
| 145 | GERRIT |
| 146 | ------ |
| 147 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 148 | |
| 149 | SEARCHBOX |
| 150 | --------- |