Documentation
Composer and Private Repositories
Sometimes it's useful to be able to split your project's plugins into their own public or private git repos. This can result in problems because the Servd Task Runner isn't able to authenticate as you with GitHub, GitLab etc.
This usually shows up as an error similar to Failed to execute git clone in the bundle creation task's logs.
There are a few different methods we can use to rectify this.
Add Your Project's SSH Key as a Repo Deploy Key #
The bundling tasks always has access to your Servd project's SSH key pair during build tasks.
If you have admin access to the repo that's failing you can add the public portion of this SSH key as a Deploy Key. This will allow composer to clone the repo.
Authenticate Using a GitHub Personal Access Token #
In order to pull repos from GitHub you'll need to create a GitHub Personal Access Token. This token can be used to access repos on your behalf.
-
Visit the Settings > Developer Settings > Tokens page on GitHub.
-
Click 'Generate New Token'.
-
Give the token a Note so that you know where it is being used.
-
Make sure all 'repo' permissions are selected.
-
Click 'Generate Token'.
-
Copy the resulting Access Token.
-
For existing projects, visit the Project Settings page in the Servd Dashboard and find the Composer Auth settings.
New projects which require a token will automatically be shown the Composer Auth dialog.
-
Add a new Auth method with the following settings:
Type: GitHub Token
Domain: github.com
Token: [paste your token]
-
Save and you're done. Your next bundle task will be able to authenticate with GitHub on your behalf.
Authenticate Using a GitLab Personal Access Token #
In order to pull repos from GitLab you'll need to create a GitLab Personal Access Token. This token can be used to access repos on your behalf.
-
Visit the User Settings > Access Tokens page on GitLab.
-
Enter a name for the new token so that you can identify it later.
-
Ensure the 'read_repository' permission is selected.
-
Click 'Create personal access token'.
-
Copy the resulting Access Token.
-
For existing projects, visit the Project Settings page in the Servd Dashboard and find the Composer Auth settings.
New projects which require a token will automatically be shown the Composer Auth dialog.
-
Add a new Auth method with the following settings:
Type: GitLab Token
Domain: gitlab.com (or your custom GitLab domain)
Token: [paste your token]
-
Save and you're done. Your next bundle task will be able to authenticate with GitLab on your behalf.
Authenticate Using a Bitbucket OAuth Consumer #
In order to pull repos from Bitbucket you'll need to create a Butbucket OAuth Consumer. This can be used to access repos on your behalf.
-
Visit the OAuth consumers page for the Workspace that owns the private repo on Bitbucket. You can find this page by clicking the Account Switcher in the bottom left corner of the page, clicking your Workspace name, clicking 'Settings' in the main nav, then 'OAuth Consumers'.
-
Click 'Add consumer'.
-
Enter a name so that you'll be able to identify the consumer later.
-
Make sure 'This is a private consumer' is selected
-
Make sure the 'Project > Read' and 'Repositories > Read' permissions are selected
-
Click 'Save'
-
Expand the details for your newly created consumer and make a note of the 'Key' and 'Secret'
-
For existing projects, visit the Project Settings page in the Servd Dashboard and find the Composer Auth settings.
New projects which require a token will automatically be shown the Composer Auth dialog.
-
Add a new Auth method with the following settings:
Type: Bitbucket Consumer
Domain: bitbucket.org
Consumer Key: [paste your key]
Consumer Secret: [paste your secret]
-
Save and you're done. Your next bundle task will be able to authenticate with Bitbucket on your behalf.
Authenticate Using HTTP Basic Auth #
Some repository platforms allow users to authenticate using Basic Auth. If you need to pull a repo from one of these platforms you can supply Basic Auth credentials to composer for it to use during bundle creation.
-
Create the basic auth user on your repo hosting platform
-
For existing projects, visit the Project Settings page in the Servd Dashboard and find the Composer Auth settings.
New projects which require a token will automatically be shown the Composer Auth dialog.
-
Add a new Auth method with the following settings:
Type: HTTP Basic Auth
Domain: [the domain name for your repo host]
Username: [basic auth username]
Password: [basic auth password]
-
Save and you're done. Your next bundle task will be able to authenticate with your git host using Basic Auth.