Enable Git Experience in a Project

Updated 2 months ago by Michael Cretzman

Currently, this feature is in Beta. Once the feature is released to a general audience, it will be available for Harness Professional, Essentials, Trial, and Community Editions.

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

Limitations

  • 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.

See Add Source Code Managers.

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.

Make sure your repo has at least one branch, such as main or master. For most Git providers, you simply add a README file to the repo and the branch in created.

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.

You do not need all of the resources used by your Pipelines to be synched to your repo. For example, you could use account-level resources such as Delegate or Docker Registry Connectors. These will work fine.

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.

Create the folder in your repo before setting up the Harness Folder. You will enter the name of the folder in Harness. Harness does not create the folder for you.

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.

Important: the Connector must use the Enable API access option and Username and Token authentication. Harness requires the token for API access. Generate the token in your account on the Git provider and add it to Harness as a Secret. Next, use the token in the credentials for the Git Connector.

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.
Secrets: if you select Connect Through Manager, the secrets are decrypted on the delegate and are available on the Harness Manager. This is different than Connect Through Delegate where the Harness Delegate decrypts the secrets. The secrets are then used in the context of the Delegate that sits in your private network. See Harness Secrets Manager 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.

Click Pipelines.

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!

Next Steps

Now that you've enabled Harness Git Experience in your Project, you can start creating Pipeline and resources and syncing them with Git.

See Git Experience How-tos.


Please Provide Feedback