GitHub or GitLab HTTP
Prerequisites
- The target repo must NOT already exist in P4 Server.
- The source repo must not be empty.
-
If the repo is private or internal, consider creating a personal access token:
- For GitHub - Creating a personal access token for the command line - https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
- For GitLab - Personal access tokens - https://docs.gitlab.com/ce/user/profile/personal_access_tokens.html
On the Git Connector server
-
Log in as the GitConnector SSH system user or the user you specified when configuring the Git Connector. (The GitConnector configuration script,
configure-git-connector.sh, sets the user name togitby default, but you can specify a different user name in the--sshuserparameter.) -
Configure the webhook for mirroring:
Copy the URL from your project's HTTP drop-down box.- 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 https://access-token:secret@GitHost.com/project/repoName.gitwhere access-token:secret represents your personal access token for GitHub or GitLab.
Use the URL to create the mirror hook. Do not create a mirror hook by using an IP address.
- Set the environment variable
-
Save the secret token that the
--mirrorhookscommand generates, which is not related to the personal access token for GitHub or GitLab.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}
Mirror a repo over HTTP
-
Go to the hooks URL, which might resemble
https://GitHost/project/repo/hooksand represents the web hook URL for your Git client:- For GitLab see https://docs.gitlab.com/ce/user/project/integrations/webhooks.html
- For GitHub, see https://developer.github.com/webhooks/creating/
-
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.