Deploying the Gerrit receive hook

Each project you registered when you deployed additions to Gerrit has a shared Gerrit repository. If you want developers to be able to add work item references to commit messages and have links created automatically when they push to this shared repository from the command line, you must deploy this hook.

Before you begin

Command line support requires the following software

About this task

You use the Gerrit receive hook to process command line commits and associate these commits to existing Rational Team Concert™ work items.

Perform these steps to install and configure the Gerrit receive hook.

Procedure

  1. Install the receive hook.
    1. Go to the folder location where you installed Rational® Adapter for Git.

      For example, JazzTeamServerDir/server/conf/gitAdapter

    2. Find the gerritHook-yyyymmdd-hhmm.zip file.
    3. Create a folder for the zip file in your Gerrit installation folder.

      For example, GerritHomeDirectory/hooks

    4. Uncompress the gerritHook-yyyymmdd-hhmm.zip file to that hooks folder.

      For example, GerritHomeDirectory/hooks

    5. All users who push to this repository must have execute permission for the patchset-created file. From the command line change to the location of your hooks folder, and type the following command.
      chmod a+x patchset-created
  2. Configure the receive hook.
    Modify the Gerrit configuration to include information about how to connect to Rational Team Concert.
    Important:
    • The user ID, password, and JTS URL can be in a Git configuration level that is shared across several repositories. However, the adapted project URI must be configured uniquely for each Git repository. The adapted project URI is the URI you were given when you registered the project from Gerrit.
    • The Gerrit receive hook user can be the same as the functional user that you set up when you created the friend relationship between the adapter and Rational Team Concert. That user that is assigned for this server to server communication does not need read access to the work items it is linking to, but requires at a minimum JazzUsers repository permissions to the repository to read and write work items in the Change and Configuration Management project areas that are used as part of the integration. This user ID is used to log in to the Jazz Team Server and to create the adapted Git resource in the Git adapter database when the request comes from the Gerrit path-set created hook. You can create another Gerrit receive hook user but this user also requires JazzUsers repository permissions to create and update work items in Rational Team Concert from the adapter. As well this user does not need a Rational Team Concert-Stakeholder Client Access License, if you are using that method of licensing for the adapter
    1. Set the following Gerrit config parameters for the specific repository under a Gerrit server. All of the parameters can be global except rtc.gerritAdaptedProjectURL. From the command line, navigate to the shared repository and type the following commands.
      Important: The Gerrit receive hook user can be the same as the functional user that you set up when you created the friend relationship between the adapter and RTC. That user was assigned for this server to server communication and had appropriate permissions to create and update work items in RTC. You can create another Gerrit receive hook user but this user must also have appropriate permissions to create and update work items in RTC from the adapter.
      git config rtc.gerritAdaptedProjectURL https://YourGerritServerURL:port/gitAdapter/YourAdaptedProjectURL 
      git config rtc.jtsURL https://YourGerritServerURL:port/YourJazzTeamServerURL 
      git config rtc.user username 
      git config rtc.password password 
  3. Restart the Gerrit server to activate the hooks.

What to do next

Use the Rational Adapter for Git, see Using the Git adapter.

Feedback