Enable Git Experience in a Project
Harness Git Experience syncs your Harness Projects and all of their Pipelines and resources with one or more Git repos. See Harness Git Experience Overview.
Once you've set up a Harness Source Code Manager (SCM), you can enable Git Experience in your Harness Project. Once enabled, you can add your Pipelines and resources and select the repos and folders where their YAML files are stored.
In this topic:
- Before You Begin
- Step 1: Add a Harness SCM
- Step 2: Create or Select the Repo
- Step 3: Create a New Project
- Step 4: Enable Harness Git Experience
- Step 5: Configure Harness Folder
- Step 6: Select Connectivity Mode
- Next Steps
Before You Begin
- Harness Git Experience Quickstart
- A Harness SCM is mandatory for Harness Git Experience. If you don’t have a SCM when you try to enable Harness Git Experience, Harness will warn you and require you set one up.
See Add Source Code Managers.
- Do not enable Harness Git Experience on a Project that already has Pipelines and resoures. You must enable Harness Git Experience on a new Project when you first create the Project.
This is a temporary limitation.
Step 1: Add a Harness SCM
Once you have set up a Harness SCM, you can enable Git Experience in your Harness Project. Once enabled, you can add your Pipelines and resources and select the repos and folders where their YAML files are stored.
Step 2: Create or Select the Repo
In the Git provider you want to use for syncing your Project, create a repo(s) for the Project.
You must have a Harness SCM set up for this Git provider. See Add Source Code Managers.
You can use multiple repos in the Harness Git Experience for a Project. For example, you could add Pipelines to one repo and Connectors to another.
Here's a new GitHub repo named GitExpDocExample.
Step 3: Create a New Project
In Harness, create a new Project. See Create Organizations and Projects.
Here's a new Project named GitExp Doc Example.
Add any team members as contributors.
When you're done you'll have a new Project containing the modules according to your license.
Step 4: Enable Harness Git Experience
In your Project, click Project Setup, and then click Git Management.
Enable Git Experience appears.
Click Enable Git Experience.
Step 5: Configure Harness Folder
The Harness Folder is the default folder for the repo where you are syncing your Project.
The Harness Folder is named .harness. This allows you to identify Harness Project YAML files in your repos.
Later, when you add Pipelines and resources to this Project, you can specify their default folders. When a Pipeline in one repo needs to access a Connector/Secret/etc in another repo at runtime, the Pipeline will always use the Connector/Secret/etc in their default branch and folder.
You can add the Project's Harness Folder at the root of your repo or in a subfolder.
In Repository name, enter a name for the repo. It's doesn't have to be the same as the Git repo name. The name you enter here will appear in Harness only. It'll identify the Project repo.
For example, here's the Repository name
GitExpDocExample after Harness Git Experience is enabled:
In Select Connector, select or create a Git Connector to the repo for your Project. For steps, see Code Repo Connectors.
Here's an example of a GitHub Connector that has the correct settings:
Once you add a Connector, in Repository URL, you should see the repo URL.
Click Test Connection. Once Harness verifies the connection, you will see Connection Successful.
In Select Harness Folder, enter the name of the folder in your repo where you want to sync.
In Select Default Branch, select the branch that you want to use, such as main.
Here's an example of the Configure Harness Folder settings for a repo and folder:
When you're ready, click Save.
Step 6: Select Connectivity Mode
In Select Connectivity Mode, you have two options:
- Connect Through Manager: Harness SaaS will connect to your Git repo whenever you make a change and Git and Harness sync.
- Connect Through Delegate: Harness will make all connections using the Harness Delegate. This option is used for Harness On-Prem frequently, but it is also used for Harness SaaS. See Harness On-Premise Overview.
If you select Connect Through Manager, and then click Save and Continue.
If you select Connect Through Delegate, select/add the Delegate you want to use. See Delegate Installation Overview.
Harness Git Experience is enabled and the new repo and folder are listed:
Step 7: Review the Harness Git Experience in your Project
Harness does not automatically add a folder to your repo until you create a Pipeline or resource like a Connector in your Project.
You can see the repo setting in your Project before creating Pipelines and resource.
In your Project, click one of you modules. In this example, we'll use Builds.
At the top of the page you can see All Repositories.
Click All Repositories and select the name of the repo you entered in Repository name earlier.
You can now select any branches from the repo.
Harness Git Experience is enabled!
Now that you've enabled Harness Git Experience in your Project, you can start creating Pipeline and resources and syncing them with Git.