From 69c6a74ef90943656f5993c9c7c005cb8f7d7314 Mon Sep 17 00:00:00 2001 From: Petri-Johan Last Date: Thu, 6 Feb 2025 10:32:39 +0200 Subject: [PATCH] Update Gerrit docs to remove admin requirement and SSH limitation --- docs/admin/code_hosts/gerrit.mdx | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/docs/admin/code_hosts/gerrit.mdx b/docs/admin/code_hosts/gerrit.mdx index a5514b9f5..6fafc14dd 100644 --- a/docs/admin/code_hosts/gerrit.mdx +++ b/docs/admin/code_hosts/gerrit.mdx @@ -21,8 +21,8 @@ A Gerrit instance can be connected to Sourcegraph as follows: ```json { "url": "https://gerrit.example.com/", // Be sure to add a trailing slash - "username": "", - "password": "", + "username": "", + "password": "", "projects": [ // If not set, all projects on the Gerrit instance will be mirrored "docs", "kubernetes/kubernetes" @@ -33,8 +33,7 @@ A Gerrit instance can be connected to Sourcegraph as follows: "authorization": {} // Marks all repositories as private. Users will be required to present valid Gerrit HTTP credentials in order to view repositories } ``` -4. The provided `username` and `password` must be the HTTP credentials of an admin account on Gerrit. See [the Gerrit HTTP documentation](https://gerrit-documentation.storage.googleapis.com/Documentation/2.14.2/user-upload.html#http) for details on how to generate HTTP credentials. -The Gerrit instance has to have HTTPS clones enabled (the default). [`download.scheme=http`](https://gerrit-review.googlesource.com/Documentation/config-gerrit.html#download). Sourcegraph cannot clone Gerrit repos via SSH. +4. The provided `username` and `password` must be the HTTP credentials of an account on Gerrit that has access to all the repositories that need to be cloned. See [the Gerrit HTTP documentation](https://gerrit-documentation.storage.googleapis.com/Documentation/2.14.2/user-upload.html#http) for details on how to generate HTTP credentials. 5. Select **Add Repositories** to create the connection. Sourcegraph will start mirroring the specified projects. If you added the `"authorization": {}` option to the configuration, and this is the first Gerrit code host connection you have created for this Gerrit instance, you might see a warning like this: @@ -42,6 +41,26 @@ If you added the `"authorization": {}` option to the configuration, and this is Simply follow the steps in the next section to configure a Gerrit authentication provider. +### Clone using SSH + +To clone using SSH, provide `"gitSSHCredential"` in the configuration: + +```json +{ + "url": "https://gerrit.example.com/", + "username": "", + "password": "", + "projects": [ + "docs", + "kubernetes/kubernetes" + ], + "gitSSHCredential": { + "privateKey": "..." // base64 encoded private key that will be used for cloning + }, + "authorization": {} +} +``` + ## Add Gerrit as an authentication provider If the `"authorization": {}` option has been set on a Gerrit code host connection, a Gerrit authentication provider will be required so that authroized users are able to search for and browse the code mirrored by that code host connection.