GitHub or GitLab SSH
Prerequisites
- The target repo must NOT already exist in P4 Server.
- The source repo must not be empty.
Configuration steps
-
On the Git Connector server, log in as the
rootuser. - Create a
.sshdirectory:Ubuntu CentOS mkdir /var/www/.ssh mkdir /usr/share/httpd/.ssh - Assign the owner of the directory:
Ubuntu CentOS chown www-data:gconn-auth /var/www/.ssh chown apache:gconn-auth /usr/share/httpd/.ssh -
Switch user from
rootto the web service user for your platform:Ubuntu CentOS su -s /bin/bash - www-datasu -s /bin/bash - apacheand generate the public and private SSH keys for the Git Connector instance:
ssh-keygen -t rsa -b 4096 -C web-service-user@gitConnector.comwhere the web-service-user is either www-data for Ubuntu or apache for CentOS.
then follow the prompts.
-
Locate the public key:
-
Copy this public key to the GitLab or GitHub server and add to the user account (p4-user) that performs clone and fetch for mirroring.
- Configure the webhook for mirroring:
- Set the environment variable
GCONN_CONFIGto the absolute path to thegconn.conffile:export GCONN_CONFIG=/opt/perforce/git-connector/gconn.conf - Add the web hook:
gconn --mirrorhooks add //graphDepotName/repoName git@GitHost.com/project/repoName.git -
Copy the URL from your project's SSH drop-down box.
-
Save the secret token that the
--mirrorhookscommand generates.The secret token is also included in the repo spec on the P4 Server. To write the repo spec to standard output, run:
p4 repo -o {//graphDepotName/repoName}
| Ubuntu | CentOS |
|---|---|
|
|
/usr/share/httpd/.ssh/id_rsa.pub |
Mirror a repo over SSH
- Go to https://GitHost.com/project/repoName/hooks
- Paste the URL of the Git Connector into the URL text box: https://GitConnector.com/mirrorhooks
- Paste the webhook secret token in the Secret Token text box.
- Uncheck Enable SSL verification.
-
Select events to trigger the webhook and click Add Webhook.
- Click the lower-right corner Test button to validate the web hook is correctly set up.