Add Source Repo Providers
You can add one or more Git repositories (Github, Bitbucket, GitLab, etc) as Source Repo Providers in Harness. Once added, a Git repo can be used to sync your Harness account and applications with your repo. Next, any changes you make in your repo or in Harness are automatically synched.
You can use multiple repositories. You can sync the Harness account-level to one repo or branch, and sync each Harness application with its own repo or branch.
Harness Sync Options
Here are the options for syncing Harness with your repos:
- One Harness application can be on one repo/branch.
- Multiple Harness applications can be on one repo, all in one branch, or each application in its own branch.
- A Harness application cannot be in multiple repos.
- When you create a new Harness application, you can choose to sync it with a repo.
- If you create a new Harness application in a synched repo (by adding the required files and folders), Harness will sync and add the new Harness application.
- If you move a synched Harness application from one repo to a new repo, Harness will accept changes from new repo only.
- Admins that want access to all synched Harness applications in the repo must have an admin account in the Git repo that contains all the applications.
Add a Source Repo Provider
To add a source repo, do the following:
- Click Setup.
- Click Connectors.
- Click Source Repo Providers, and then click Add Source Repo Provider. The Git Connector dialog appears.
- Fill out the Git Connector dialog and click SUBMIT. The Git Connector dialog has the following fields.
Enter a name for the repo connection. This is the name you will select when you sync your Harness account and applications in Configuration as Code.
Select HTTPS or SSH for the connection. You will need to provide the protocol-relevant URL in URL.
For SSH, ensure that the key is not OpenSSH, but rather RSA or another algorithm.
If you log into Bitbucket using a Google account, you can create an application password in Bitbucket to use with Harness. For steps on this, see App passwords from Atlassian.
Enter the URL for your Git repo. Ensure it matches the option you selected in HTTPS/SSH.
Username and Password/Token
Enter the credentials for the repo user account.
If you have set up Two Factor Authentication in your Git repo, then you need to generate a personal access token in your repo and enter that token in the Password/Token field. In Github, you can set up the personal access token at https://github.com/settings/tokens/new.
If you selected SSH as the connection protocol, you must add the SSH Key for use with the connection. If you added a key in Harness Secrets Management, you can select it here. For more information, see Secrets Management.
Enter the branch name to sync with Harness, such as master, dev, or myAppName. Do not enter the full URL to the branch.
Generate Webhook URL
Enable this checkbox if you want to sync Harness with your repo bidirectionally. Changes made on either end will be synched. If you simply want Harness changes synched unidirectionally with the repo, disable this checkbox.
Customize Commit Attributes (Git Sync Only)
When Harness commits or push a change to Git as part of synching, it uses Harness.io and firstname.lastname@example.org as the author and commit email address of that commit.
In some cases, you might have strong pre-commit limitations on who may or may not commit. In that case, you need to provide an author name and email that is approved to push on that repo.
If you want to restrict the use of a provider to specific applications and environments, do the following:
In Usage Scope, click the drop-down under Applications, and click the name of the application.
In Environments, click the name of the environment.
Using the Webhook
If you selected the Generate Webhook URL option when adding your Source Repo Provider, the Generated Webhook URL dialog appears. Copy the URL and use it in your repo to enable your repo to sync changes to Harness.
Use the Repository push event trigger.
For information on Bitbucket Webhooks, see Manage webhooks from Bitbucket.
Use the Push events trigger.
Once a Source Repo Provider is set up, you can use it at the Harness account-level and application-level to sync your account and/or applications with your Git repo. For more information, see Configuration as Code.