Harness lets you create a Pipeline in the following ways:
- Create an inline Pipeline and save its configuration in Harness.
- Create a remote Pipeline and save its configuration in Git.
- Import a Pipeline from Git and save its configuration in Git.
This topic explains how to import a Pipeline from your Git repo to Harness.
Before you begin
- Harness Git Experience Overview
- Harness Git Experience Quickstart
- Manage a Harness Pipeline Repo Using Git Experience
- Make sure you have Create/Edit permissions for Pipelines.
Step: Import pipeline
You can import a Pipeline from the CI or CD module in Harness.
This topic shows you how to import a Pipeline to the CD module.
In Harness, click Deployments.
Select your Project and click on Pipelines.
Select Import From Git.
The Import Pipeline From Git settings appear.
Enter a Name for your Pipeline.
In Git Connector, select or create a Git Connector to connect to your Git repo. For steps, see Code Repo Connectors.
IMPORTANT: Connector must use the Enable API access option and Token
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.
For GitHub, the token must have the following scopes:
Here's an example of a GitHub Connector that has the correct settings:
In Repository, select the repository from where you want to import the Pipeline. If your repository isn't listed, enter its name since only a select few repositories are filled here.
Create the repository in Git before entering it in Select Repository. Harness does not create the repository for you.
- In Git Branch, select the branch from where you want to import the Pipeline. If your branch isn't listed, enter its name since only a select few branches are filled here.
Create the branch in your repository before entering it in Git Branch. Harness does not create the branch for you.
- Enter the YAML Path from where you want to import the Pipeline. All your configurations are stored in Git in the Harness Folder.
Make sure that your YAML path starts with
.harness/ and the YAML file already exists in the specified Git repo and branch.
- Click Import.
Click on your Pipeline to proceed.
By default, Harness fetches your Pipeline details from the default branch. If you have imported Pipeline from some other branch you will see the below error. Select the branch from where you imported the Pipeline and continue.