Gerrit Productivity Hacks – Add Default Reviewer

We often get requests from the TeamForge users who’re using Git Integration for the one very common use case:  “How can I add a default reviewer to the code review request ? ”

Well, answer became much simpler with Gerrit’s  Reviewer plugin  and Gerrit 2.11 with which plugin can be configured per project with the comfort of Gerrit webUI.

Installation

The verified version of the plugin can be downloaded or install directly.

Download and install

wget https://s3-ap-southeast-1.amazonaws.com/ctf-dev-environment-vagrant/reviewers.jar
ssh -p 29418 <USERNAME>@<GERRIT_HOST>  gerrit plugin install -n reviewers.jar  -< reviewers.jar

Direct install

ssh -p 29418 <USERNAME>@<GERRIT_HOST>  gerrit plugin install -n reviewers.jar  - https://s3-ap-southeast-1.amazonaws.com/ctf-dev-environment-vagrant/reviewers.jar

Replace USERNAME with the user with administrators user and GERRIT_HOST  with the hostname of your Git integration server. In the future release of Gerrit 2.11, this plugin will be bundled so going forward it will not require to install it separately.

Usage

Plugin allows to configure default reviewer(s) per repository.

Go to Gerrit WebUI->project menu bar-> List-> Select project (repository name in TeamForge)

Click on the Reviewers tab

 Here you can specify filter and the default reviewer.

 reviewer can be added by name or email address.

filter can be of multiple types:

  1. *  (wildcard)  for any code review request  for this repository
  2. branch:master   for any code review request for the branch
  3. branch:release file:^lib/.* for any code review request for the release branch which involves change in lib directory

 

 Now with this configuration in place, any new change will have reviewer added as per configuration.

That’s it. Very easy. isn’t it?  Add your peers as a default reviewer and get their attention easily !

Dharmesh Sheta

Dharmesh is a Senior Integration Engineer at CollabNet and works with team for Gerrit/Git product solutions in Germany. He has 8+ years experience in Continuous Integration, SW build & release processes, test automation, SW development tooling and infrastructure. Prior to CollabNet, he spent ~4 years at Nokia and was part of core team responsible for CI processes and infrastructure for global SW dev. teams. Dharmesh holds M.Sc in SW Engineering from Leuphana University of Lüneburg, Germany and graduated from VNSGU, India.

Posted in Enterprise Git, Git, TeamForge
2 comments on “Gerrit Productivity Hacks – Add Default Reviewer
  1. Here are follow up notes for those who are interested in using reviewers plugin in newer releases of TeamForge Git Integration.

    Note1:
    Reviewers plugin is bundled with plugins delivered as a part of TeamForge Git Integration version 8.5.1-3+ (based on 2.11.5 Gerrit Community version) however not installed by default.
    In order to install it one needs to add ‘reviewers’ entry to ~gerrit/doc/pluginlist file and run post-install.py again. Note that Gerrit service will be restarted.

    Note2:
    In Gerrit 2.12 there is no longer ‘fancy’ UI for plugin configuration – see Gerrit->Plugins->Installed->reviewers Configuration for details, but to sum it up, in order to configure reviewers one needs to:
    1. go to Projects->[project name]->General tab and select ‘Create Change’ button
    2. provide refs/meta/config for ‘Select branch for new Change’ field and whatever is suitable for remaining fields
    3. once new Draft is created select ‘Edit’ and ‘Add…’ buttons in order to add reviewers.config file
    4. in body configure rules for default reviewers addition according to the plugin Configuration mentioned above for instance (means that user@example.com will be added for every review):

    [filter “*”]
    reviewer = user@example.com

    5. select ‘Save’ and ‘Close’ and ‘Publish Edit’ buttons to apply your changes and ‘Publish’ button to switch from Draft to regular change. Once it is reviewed and submitted it will be automatically picked up by reviewers plugin (no restart is required).
    Your job is done 🙂

  2. Subramanian says:

    Adding to the above information you can still add ‘reviewers’ entry to ~gerrit/doc/pluginlist even in Gerrit 2.13.x with CTF 17.x and do a provision/deploy of gerrit.

    This will install the reviewers plugin and reviewers tab will be enabled in gerrit.

Leave a Reply

Your email address will not be published. Required fields are marked *

*