Code Stream lets you trigger a pipeline when a code review occurs in your Gerrit project. The trigger for Gerrit definition includes the Gerrit project and the pipelines that must run for different event types.

The trigger for Gerrit uses a Gerrit listener on the Gerrit server that you will monitor. To define a Gerrit endpoint in Code Stream, you select a project and enter the URL for the Gerrit server. Then you specify the endpoint when you create a Gerrit listener on that server.

The following procedure shows how to define a Gerrit endpoint that you can use in your Gerrit listener definition. In the event that you need to edit an endpoint, an optional step at the end of the procedure explains how and when to perform the update.

Prerequisites

Procedure

  1. Define a Gerrit endpoint.
    1. Click Configure > Endpoints and click New Endpoint.
    2. Select a project, and for the type of endpoint, select Gerrit. Then, enter a name and a description.
    3. If this endpoint is a business-critical component in your infrastructure, enable Mark as restricted.
    4. Enter the URL for the Gerrit server.
      To use the default port, you can provide a port number with the URL or leave the value blank.
    5. Enter a username and password for the Gerrit server.
      If the password must be encrypted, click Create Variable and select the type:
      • Secret. The password resolves when a user who has any role runs the pipeline.
      • Restricted. The password resolves when a user who has the Admin role runs the pipeline.

      For the value, enter the password that must be secure, such as the password of a Jenkins server.

    6. For the private key, enter the SSH key used to access the Gerrit server securely.
      This key is the RSA private key that resides in the .ssh directory.
    7. (Optional) If a passphrase is associated with the private key, enter the passphrase.
      To encrypt the passphrase, click Create Variable and select the type:
      • Secret. The password resolves when a user who has any role runs the pipeline.
      • Restricted. The password resolves when a user who has the Admin role runs the pipeline.

      For the value, enter the passphrase that must be secure, such as the passphrase for an SSH server.

  2. Click Validate, and verify that the Gerrit endpoint in Code Stream connects to the Gerrit server.
    If it does not connect, correct any errors, then click Validate again.
    When you add an endpoint for the Gerrit trigger, you must confirm that the Gerrit endpoint connects to the Gerrit server.
  3. Click Create.
  4. (Optional) Before updating a Gerrit endpoint to change a URL or private key for example, check to see if the endpoint is connected to a Gerrit listener.
    • If the endpoint is not connected to a Gerrit listener, perform the following steps to update the endpoint:
      1. Click Configure > Endpoints and click Open on the endpoint that you want to update.
      2. Update the endpoint definition.
      3. (Optional) If you are changing the cloud proxy, restart the old cloud proxy once to remove any old connections before starting the new cloud proxy and establishing a new connection.
      4. click Validate to verify that the Gerrit endpoint in Code Stream connects to the Gerrit server.
      5. Click Save.
    • If the endpoint is connected to a Gerrit listener, perform the following steps to update the endpoint:
      1. Disconnect any attached Gerrit listeners. See How do I use the Gerrit trigger in Code Stream to run a pipeline.
      2. Perform the steps to configure the new endpoint.
      3. (Optional) If you are changing the cloud proxy, restart the old cloud proxy once to remove any old connections before starting the new cloud proxy and establishing a new connection.
      4. Validate and save the updated endpoint definition.
      5. Connect the Gerrit listeners again.
      Note: If the Gerrit listeners do not disconnect, this might be because current Gerrit endpoint values have changed so that the listeners can no longer communicate with the Gerrit server. If this problem occurs, first make changes in the endpoint definition so that the listeners can communicate with the Gerrit server. Then disconnect the Gerrit listeners and reconnect them.

What to do next

To learn more, review the other sections. See How do I use the Gerrit trigger in Code Stream to run a pipeline.