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.

  1. Visit the Settings > Developer Settings > Tokens page on GitHub.

  2. Click 'Generate New Token'.

  3. Give the token a Note so that you know where it is being used.

  4. Make sure all 'repo' permissions are selected.

  5. Click 'Generate Token'.

  6. Copy the resulting Access Token.

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

  8. Add a new Auth method with the following settings:

    Type: GitHub Token

    Domain: github.com

    Token: [paste your token]

  9. 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.

  1. Visit the User Settings > Access Tokens page on GitLab.

  2. Enter a name for the new token so that you can identify it later.

  3. Ensure the 'read_repository' permission is selected.

  4. Click 'Create personal access token'.

  5. Copy the resulting Access Token.

  6. 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.

  7. Add a new Auth method with the following settings:

    Type: GitLab Token

    Domain: gitlab.com (or your custom GitLab domain)

    Token: [paste your token]

  8. 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.

  1. 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'.

  2. Click 'Add consumer'.

  3. Enter a name so that you'll be able to identify the consumer later.

  4. Make sure 'This is a private consumer' is selected

  5. Make sure the 'Project > Read' and 'Repositories > Read' permissions are selected

  6. Click 'Save'

  7. Expand the details for your newly created consumer and make a note of the 'Key' and 'Secret'

  8. 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.

  9. 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]

  10. 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.

  1. Create the basic auth user on your repo hosting platform

  2. 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.

  3. 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]

  4. Save and you're done. Your next bundle task will be able to authenticate with your git host using Basic Auth.