For the complete documentation index, see llms.txt. This page is also available as Markdown.

Add a Git connector

Add a Git connector so Harness pipelines can pull code and other files from any Git-compatible provider that does not have a dedicated connector.

The Git connector is the Harness platform-agnostic code repository connector. Git is the underlying distributed version control system used by GitHub, GitLab, Bitbucket, Azure Repos, and many other providers. The Git connector uses standard Git commands to connect securely over the web or SSH. It works with any provider that exposes a standard Git remote, including self-hosted Git servers, various SaaS providers, and services like AWS CodeCommit, without requiring a provider-specific integration.

Go to Overview for information about all code repos connectors, such as scopes, permissions and connectivity modes.

What you will learn from this topic

  • How to add a Git connector to a Harness project so pipelines can pull code from any Git-compatible provider.


When to use the Git connector instead of a dedicated connector

Use the Git connector when:

  • Harness does not offer a dedicated connector for your Git provider.

  • Your Git provider is API-compatible with plain Git over HTTP or SSH, and you do not need provider-specific features such as PR status checks tied to a dedicated connector type.

Use a dedicated connector if it exists

If a dedicated connector exists for your provider (Azure Repos, Bitbucket, GitHub, or GitLab), Harness recommends using it instead. Dedicated connectors support provider-specific features such as GitHub Apps, Azure Repos API access, and provider-aware webhooks that the Git connector does not.


Before you begin

Before you create a Git connector, ensure you have:

  • A Git repository reachable over HTTP(S) or SSH.

  • A username and password or token, or an SSH key, with permission to read (and, if needed, clone) the repository.

  • Permission to create connectors in Harness.


Add a Git connector

You can add a Git connector at the project, org, or account scope. This procedure covers the project scope, and the process is the same for org and account.

You can also add a Git connector directly when configuring a codebase or artifact source in a pipeline or service.

Follow the interactive guide below for a step-by-step walkthrough:

spinner
Add a platform-agnostic Git connector in Harness

Perform the following steps to add a Git connector:

  1. Open your Harness project.

  2. In Project Settings, select Connectors.

  3. Click New Connector, then select Git. The Git Connector settings appear.

Overview

Configure the identity fields for the connector.

In Name, enter a name for the connector. Optionally, add a description and tags. Click Continue.

Details

Configure the following details:

  1. For URL Type, select one of:

    • Account: Connect to an entire Git account or organization. The connector can be used for every repository in that account.

    • Repository: Connect to a single Git repository.

  2. For Connection Type, select HTTP or SSH.

  3. Enter the Git Account URL or Git Repository URL, depending on the URL Type you selected. The format depends on your Git provider and Connection Type. For example:

    • HTTP format: https://<git-provider>.com/USERNAME/REPO_NAME

    • SSH format: git@<git-provider>.com:USERNAME/REPO_NAME

    For SSH, the URL is valid only if it starts with the prefix git@.

  4. If you selected Account for URL Type, enter a Test Repository. Harness uses this repository only to validate the connection. You specify the actual repository to use when you reference the connector in a pipeline.

  5. Click Continue.

Credentials

Configure the credentials based on the connection type you selected:

Go to Git connector settings reference for detailed information on Git connection settings.

Select Connectivity Mode

Select how Harness connects with your Git provider:

  • Connect through Harness Platform: Use a direct, secure communication between Harness and your Git provider. All credentials are encrypted and stored in the Secret Manager configured in Harness. This connectivity mode is required for Harness Cloud build infrastructure.

  • Connect through a Harness Delegate: Harness communicates with your Git provider through a Harness Delegate you install in your environment, behind your corporate firewall.

Delegates Setup

If you selected Connect through a Harness Delegate, select either:

  • Use any available Delegate: Harness selects an available delegate at runtime.

  • Only use Delegates with all of the following tags: Select specific delegates for Harness to use with this connector.

Click Save and Continue.

Test Connection

Click Finish after the connection test succeeds. The connector is listed in Connectors.

If the connection test fails:

  • Confirm the repository or account URL matches the format for your selected Connection Type. HTTP URLs must start with https://, and SSH URLs must start with git@.

  • Confirm the username and password, token, or SSH key has the required permissions on the repository.

  • If you are connecting through a delegate, confirm the delegate can reach your Git server over the network, and that split DNS, proxy, or firewall configurations are not blocking the connection.


Sample YAML

The following example shows a YAML for the Git connector created in this guide.

YAML - Git connector

For the full connector YAML schema, including how to skip connector preflight checks, go to Create a connector using YAML.


Next steps

Last updated

Was this helpful?