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.
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:
Perform the following steps to add a Git connector:
Open your Harness project.
In Project Settings, select Connectors.
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:
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.
For Connection Type, select HTTP or SSH.
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_NAMESSH format:
git@<git-provider>.com:USERNAME/REPO_NAME
For SSH, the URL is valid only if it starts with the prefix
git@.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.
Click Continue.
Credentials
Configure the credentials based on the connection type you selected:
If you selected HTTP:
Username: Enter the username for the account. You can use plaintext or a Harness encrypted text secret.
Password: Select or create a new Harness encrypted text secret to store your password, personal access token, or app password, depending on your provider.
If you selected SSH:
Select or create a new Harness SSH credential secret to store your SSH key. The SSH credential's Username must be
git.
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 withgit@.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.
For the full connector YAML schema, including how to skip connector preflight checks, go to Create a connector using YAML.
Next steps
Use delegate selectors: control which delegates can connect to this connector.
Add a secret manager: store connector credentials in a secret manager instead of the Harness built-in secret manager.
Last updated
Was this helpful?