> For the complete documentation index, see [llms.txt](https://docs.warp.dev/llms.txt).
> Markdown versions of each page are available by appending .md to any URL.

# Connecting other code forges to your factory

Connect a factory to a repository from another code forge using Agent Secrets and setup commands on the default runner.

Connect your factory to a repository on Bitbucket, Azure DevOps Server, self-managed GitLab, or another code forge without first-class factory support. Hosted Azure DevOps Services repositories use the [first-class Azure DevOps integration](https://docs.warp.dev/factories/integrations/azure-devops/). For other code forges, create the factory with no connected repository, then clone the repository from its default runner.

Caution

This setup gives factory agents repository access. It does not add provider-specific events or automations for the code forge.

## Prerequisites

-   **Factory access** - Permission to create the factory, add Agent Secrets, and edit its default runner.
-   **Repository access** - An HTTPS clone URL and a token that can read the repository.

For provider-specific token and clone formats, see [Bitbucket repository access](https://docs.warp.dev/platform/integrations/bitbucket/) or [self-managed GitLab repository access](https://docs.warp.dev/platform/integrations/gitlab/#self-managed-gitlab-instances).

### Azure DevOps Server credentials

Before you create the factory, generate a personal access token for your Azure DevOps Server repository:

1.  Sign in to your Azure DevOps Server instance at `https://SERVER/COLLECTION`.
2.  Click the user settings icon, then click **Personal access tokens**.
3.  Click **\+ New Token**, then enter a name and choose an expiration date.
4.  Under “Scopes,” choose **Custom defined**, then select **Code** > **Read**. Select **Code** > **Read & Write** instead if agents need to push commits.
5.  Click **Create**, then copy the token. Azure DevOps doesn’t show it again.

Store this token as the `CODE_FORGE_TOKEN` Agent Secret by following [Grant the clone credential](#grant-the-clone-credential).

## Create the factory without a repository

To prepare a repository from the default runner, create the factory without a code-host connection.

1.  In the [Warp Factories web app](https://platform.warp.dev), click **+** next to **Factories**.
2.  Under **Connect your code host**, select **No repo**.
3.  Complete the remaining setup choices to create the factory.

The factory opens in its dashboard without a connected repository.

## Grant the clone credential

Store the repository token as an Agent Secret so the default runner can use it without placing the token in a command or definition file.

1.  From the [Warp Factories web app](https://platform.warp.dev), click **Secrets**.
2.  Create an Agent Secret named `CODE_FORGE_TOKEN`.
3.  Enter the repository access token as the secret value, then grant `CODE_FORGE_TOKEN` to the factory agents that use the default runner.

The secret is available to those agents and their runner setup commands as the `CODE_FORGE_TOKEN` environment variable.

## Clone the repository from the default runner

Runner setup commands prepare each agent workspace before factory work starts.

1.  From the factory dashboard, click **Settings** and scroll down to the “Runners” section.
2.  Next to the default runner, click the edit button. In the “Setup commands” section, click **+** and add an authenticated `git clone` command that reads `$CODE_FORGE_TOKEN`.
3.  Add any other project setup commands the repository needs, such as dependency installation, builds, or code generation.

Use your code forge’s documented clone format. For example, Bitbucket Cloud requires the `x-bitbucket-api-token-auth` username, while other hosts use a different username or authorization header.

For Azure DevOps Server, add this setup command:

```bash
if [ ! -d "REPO/.git" ]; then
  git -c http.extraheader="Authorization: Basic $(printf ':%s' "$CODE_FORGE_TOKEN" | base64 | tr -d '\n')" \
    clone "https://SERVER/COLLECTION/PROJECT/_git/REPO" "REPO"
fi
```

Replace `SERVER` with your Azure DevOps Server hostname and `COLLECTION`, `PROJECT`, and `REPO` with the repository path and local directory name.

Setup commands run each time the runner prepares a workspace. Make the commands safe to run repeatedly.

## Test repository access

Start a direct factory run before you connect another work source.

1.  In the factory dashboard, open **Runs** and click **New**.
    
2.  Send a read-only request such as:
    
    ```text title="Test repository access"
    In the repository root, list the top-level files and report the current
    branch. Do not change any files.
    ```
    
3.  Confirm that the run reports files from the cloned repository.
    

If the run cannot clone the repository, confirm that the Agent Secret is granted to the agent, the token has repository read access, and the clone command uses the token environment variable correctly.

## Starting work

This code forge cannot start factory work from its own repository events. Start work from a connected service such as [Slack](https://docs.warp.dev/factories/integrations/slack/), [Linear](https://docs.warp.dev/factories/integrations/linear/), or [Jira](https://docs.warp.dev/factories/integrations/jira/), through a [custom webhook](https://docs.warp.dev/factories/webhooks/), or with a direct factory run.

## Related pages

-   [Connect GitHub to your factory](https://docs.warp.dev/factories/integrations/github/) - Use GitHub’s first-class code-forge connection.
-   [Connect GitLab to your factory](https://docs.warp.dev/factories/integrations/gitlab/) - Use GitLab.com’s first-class code-forge connection.
-   [Connect your factory](https://docs.warp.dev/factories/connect-your-factory/) - Add the sources that start work after the repository is available.
-   [Cloud agent secrets](https://docs.warp.dev/platform/secrets/) - Store and scope credentials for cloud agents.
