Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame^] | 1 | = Project Owner Guide |
| 2 | |
| 3 | This is a Gerrit guide that is dedicated to project owners. It |
| 4 | explains the many possibilities that Gerrit provides to customize the |
| 5 | workflows for a project. |
| 6 | |
| 7 | [[project-owner]] |
| 8 | == What is a project owner? |
| 9 | |
| 10 | Being project owner means that you own a project in Gerrit. |
| 11 | Technically this is expressed by having the |
| 12 | link:access-control.html#category_owner[Owner] access right on |
| 13 | `refs/*` on that project. As project owner you have the permission to |
| 14 | edit the access control list and the project settings of the project. |
| 15 | It also means that you should get familiar with these settings so that |
| 16 | you can adapt them to the needs of your project. |
| 17 | |
| 18 | Being project owner means being responsible for the administration of |
| 19 | a project. This requires having a deeper knowledge of Gerrit than the |
| 20 | average user. Normally per team there should be 2 to 3 persons, who |
| 21 | have a certain level of Git/Gerrit knowledge, assigned as project |
| 22 | owners. It normally doesn't make sense that everyone in a team is |
| 23 | project owner. For normal team members it is sufficient to be committer |
| 24 | or contributor. |
| 25 | |
| 26 | [[access-rights]] |
| 27 | == Access Rights |
| 28 | |
| 29 | As a project owner you can edit the access control list of your |
| 30 | project. This allows you to grant permissions on the project to |
| 31 | different groups. |
| 32 | |
| 33 | Gerrit comes with a rich set of permissions which allow a very |
| 34 | fine-grained control over who can do what on a project. Access |
| 35 | control is one of the most powerful Gerrit features but it is also a |
| 36 | rather complex topic. This guide will only highlight the most |
| 37 | important aspects of access control, but the link:access-control.html[ |
| 38 | Access Control] chapter explains all the details. |
| 39 | |
| 40 | [[edit-access-rights]] |
| 41 | === Editing Access Rights |
| 42 | |
| 43 | To see the access rights of your project |
| 44 | |
| 45 | - go to the Gerrit WebUI |
| 46 | - click on the `Projects` > `List` menu entry |
| 47 | - find your project in the project list and click on it |
| 48 | - click on the `Access` menu entry |
| 49 | |
| 50 | By clicking on the `Edit` button the access rights become editable and |
| 51 | you may save any changes by clicking on the `Save Changes` button. |
| 52 | Optionally you can provide a `Commit Message` to explain the reasons |
| 53 | for changing the access rights. |
| 54 | |
| 55 | The access rights are stored in the project's Git repository in a |
| 56 | special branch called `refs/meta/config`. On this branch there is a |
| 57 | `project.config` file which contains the access rights. More |
| 58 | information about this storage format can be found in the |
| 59 | link:config-project-config.html[Project Configuration File Format] |
| 60 | chapter. What is important to know is that by looking at the history |
| 61 | of the `project.config` file on the `refs/meta/config` branch you can |
| 62 | always see how the access rights were changed and by whom. If a good |
| 63 | commit message is provided you can also see from the history why the |
| 64 | access rights were modified. |
| 65 | |
| 66 | If a Git browser such as GitWeb is configured for the Gerrit server you |
| 67 | can find a link to the history of the `project.config` file in the |
| 68 | WebUI. Otherwise you may inspect the history locally. If you have |
| 69 | cloned the repository you can do this by executing the following |
| 70 | commands: |
| 71 | |
| 72 | ==== |
| 73 | $ git fetch origin refs/meta/config:config |
| 74 | $ git checkout config |
| 75 | $ git log project.config |
| 76 | ==== |
| 77 | |
| 78 | Non project owners may still edit the access rights and propose the |
| 79 | modifications to the project owners by clicking on the `Save for |
| 80 | Review` button. This creates a new change with the access rights |
| 81 | modifications that can be approved by a project owner. The project |
| 82 | owners are automatically added as reviewer on this change so that they |
| 83 | get informed about it by email. |
| 84 | |
| 85 | [[inheritance]] |
| 86 | === Inheritance |
| 87 | |
| 88 | Normally when a new project is created in Gerrit it already has some |
| 89 | access rights which are inherited from the parent projects. |
| 90 | Projects in Gerrit are organized hierarchically as a tree with the |
| 91 | `All-Projects' project as root from which all projects inherit. Each |
| 92 | project can have only a single parent project, multi-inheritance is |
| 93 | not supported. |
| 94 | |
| 95 | Looking at the access rights of your project in the Gerrit WebUI, you |
| 96 | only see the access rights which are defined on that project. To see |
| 97 | the inherited access rights you must follow the link to the parent |
| 98 | project under `Rights Inherit From`. |
| 99 | |
| 100 | Inherited access rights can be overwritten unless they are defined as |
| 101 | link:access-control.html#block[BLOCK rule]. BLOCK rules are used to |
| 102 | limit the possibilities of the project owners on the inheriting |
| 103 | projects. With this, global policies can be enforced on all projects. |
| 104 | Please note that Gerrit doesn't prevent you from assigning access |
| 105 | rights that contradict an inherited BLOCK rule, but these access rights |
| 106 | will simply have no effect. |
| 107 | |
| 108 | If you are responsible for several projects which require the same |
| 109 | permissions, it makes sense to have a common parent for them and to |
| 110 | maintain the access rights on that common parent. Changing the parent |
| 111 | of a project is only allowed for Gerrit administrators. This means you |
| 112 | need to contact the administrator of your Gerrit server if you want to |
| 113 | reparent your project. One way to do this is to change the parent |
| 114 | project in the WebUI, save the modifications for review and get the |
| 115 | change approved and merged by a Gerrit administrator. |
| 116 | |
| 117 | [[refs]] |
| 118 | === References |
| 119 | |
| 120 | Access rights in Gerrit are assigned on references (aka refs). Refs in |
| 121 | Git exist in different namespaces, e.g. all branches normally exist |
| 122 | under `refs/heads/` and all tags under `refs/tags/`. In addition there |
| 123 | are a number of link:access-control.html#references_special[special refs] |
| 124 | and link:access-control.html#references_magic[magic refs]. |
| 125 | |
| 126 | Access rights can be assigned on a concrete ref, e.g. |
| 127 | `refs/heads/master` but also on ref patterns and regular expressions |
| 128 | for ref names. |
| 129 | |
| 130 | A ref pattern ends with `/*` and describes a complete ref name |
| 131 | namespace, e.g. access rights assigned on `refs/heads/*` apply to all |
| 132 | branches. |
| 133 | |
| 134 | Regular expressions must start with `^`, e.g. access rights assigned |
| 135 | on `^refs/heads/rel-.*` would apply to all `rel-*` branches. |
| 136 | |
| 137 | [[groups]] |
| 138 | === Groups |
| 139 | |
| 140 | Access rights are granted to groups. It is useful to know that Gerrit |
| 141 | maintains its own groups internally but also supports different external |
| 142 | group backends. |
| 143 | |
| 144 | The Gerrit internal groups can be seen in the Gerrit WebUI by clicking |
| 145 | on the `Groups` > `List` menu entry. By clicking on a group you can |
| 146 | edit the group members (`Members` tab) and the group options |
| 147 | (`General` tab). |
| 148 | |
| 149 | Gerrit internal groups contain users as members, but can also include |
| 150 | other groups, even external groups. |
| 151 | |
| 152 | Every group is owned by an owner group. Only members of the owner |
| 153 | group can administrate the owned group (assign members, edit the group |
| 154 | options). A group can own itself; in this case members of the group |
| 155 | can, for example, add further members to the group. When you create new |
| 156 | groups for your project to assign access rights to committer or other |
| 157 | roles, make sure that they are owned by the project owner group. |
| 158 | |
| 159 | An important setting on a group is the option |
| 160 | `Make group visible to all registered users.`, which defines whether |
| 161 | non-members can see who is member of the group. |
| 162 | |
| 163 | New internal Gerrit groups can be created under `Groups` > |
| 164 | `Create New Group`. This menu is only available if you have the global |
| 165 | capability link:access-control.html#capability_createGroup[Create Group] |
| 166 | assigned. |
| 167 | |
| 168 | Gerrit also has a set of special |
| 169 | link:access-control.html#system_groups[system groups] that you might |
| 170 | find useful. |
| 171 | |
| 172 | External groups need to be prefixed when assigning access rights to |
| 173 | them, e.g. link:access-control.html#ldap_groups[LDAP group names] need |
| 174 | to be prefixed with `ldap/`. |
| 175 | |
| 176 | If the link:https://gerrit-review.googlesource.com/#/admin/projects/plugins/singleusergroup[ |
| 177 | singleusergroup] plugin is installed you can also directly assign |
| 178 | access rights to users, by prefixing the username with `user/` or the |
| 179 | user's account ID by `userid/`. |
| 180 | |
| 181 | [[common-access-rights]] |
| 182 | === Common Access Rights |
| 183 | |
| 184 | Different roles in a project, such as developer (committer) or |
| 185 | contributor, need different access rights. Examples for which access |
| 186 | rights are typically assigned for which role are described in the |
| 187 | link:access-control.html#example_roles[Access Control] chapter. |
| 188 | |
| 189 | [[code-review]] |
| 190 | === Code Review |
| 191 | |
| 192 | Gerrit's main functionality is code review, however using code review |
| 193 | is optional and you may decide to only use Gerrit as a Git server with |
| 194 | access control. Whether you allow only pushes for review or also |
| 195 | direct pushes depends on the project's access rights. |
| 196 | |
| 197 | To push a commit for review it must be pushed to |
| 198 | link:access-control.html#refs_for[refs/for/<branch-name>]. This means |
| 199 | the link:access-control.html#category_push_review[Push] access right |
| 200 | must be assigned on `refs/for/<branch-name>`. |
| 201 | |
| 202 | To allow direct pushes and bypass code review, the |
| 203 | link:access-control.html#category_push_direct[Push] access right is |
| 204 | required on `refs/heads/<branch-name>`. |
| 205 | |
| 206 | By pushing for review you are not only enabling the review workflow, |
| 207 | but you can also get automatic verifications from a build server |
| 208 | before changes are merged. In addition you can benefit from Gerrit's |
| 209 | merge strategies that can automatically merge/rebase commits on server |
| 210 | side if necessary. You can control the merge strategy by configuring |
| 211 | the link:project-setup.html#submit_type[submit type] on the project. |
| 212 | If you bypass code review you always need to merge/rebase manually if |
| 213 | the tip of the destination branch has moved. Please keep this in mind |
| 214 | if you choose to not work with code review because you think it's |
| 215 | easier to avoid the additional complexity of the review workflow; it |
| 216 | might actually not be easier. |
| 217 | |
| 218 | You may also enable link:user-upload.html#auto_merge[auto-merge on |
| 219 | push] to benefit from the automatic merge/rebase on server side while |
| 220 | pushing directly into the repository. |
| 221 | |
| 222 | GERRIT |
| 223 | ------ |
| 224 | Part of link:index.html[Gerrit Code Review] |
| 225 | |
| 226 | SEARCHBOX |
| 227 | --------- |