Code Streamlets 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.

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.
      You can provide a port number with the URL or leave the value blank to use the default port.
    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.

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.