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