> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/internal-developer-portal/use-idp/software-catalog/create-entity/catalog-discovery/integrations/harness-code-repository.md). Agents can also search and read this documentation through its [MCP server](https://developer.harness.io/~gitbook/mcp).

# Harness Code Repository

Set up the Harness Code Repository integration to import repositories and AI assets into Harness IDP.

The Harness Code Repository (HCR) integration discovers repositories and AI assets from [Harness Code Repository](https://developer.harness.io/code-repository/new-to-harness-code/overview) and brings them into the IDP Catalog. You can register discovered repositories as new catalog entities or merge them into existing ones. Developers then view repository details and pull requests on the **Source Code** tab of the catalog entity.

Similar to the [GitHub integration](https://developer.harness.io/internal-developer-portal/use-idp/software-catalog/create-entity/catalog-discovery/integrations/github.md), the HCR integration discovers repositories and AI assets, but it does not need a connector or token, because the data is already in your Harness account. The integration is unidirectional: data flows from Harness Code Repository into the IDP Catalog, and changes you make on a catalog entity are not written back to HCR.

For each entity type, the integration provides the following:

| Entity         | What it provides                                                                                                                                                    |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Repository** | Repository metadata such as name, visibility, language, pull request counts, latest Git tag, and many more. A list of pull requests appears on the Source Code tab. |
| **AI Assets**  | AI asset metadata (plugins, skills, agents, and commands) discovered in your Harness Code repositories.                                                             |

***

## Before you begin

Make sure the following prerequisites are met:

* The **`IDP_INTEGRATIONS`** and **`IDP_CODE_INTEGRATIONS`** feature flags are enabled for your account. Contact [Harness Support](https://www.harness.io/support) to enable them.
* **Code Repository** module is enabled on the same account you use for Harness IDP, and the account has at least one repository.
* You have the **IDP Integration Edit** permission (`IDP_INTEGRATION_EDIT`) on the **IDP Integration** resource type (`IDP_INTEGRATION`).

{% hint style="info" %}
You can create only one Harness Code Repository integration per account, and only at the account scope. You cannot create HCR integration at the organization or project scope.
{% endhint %}

***

## Create the Harness Code Repository integration

### 1. Navigate to the integrations page

To open the integrations page, complete the following steps:

1. In Harness, open the **Internal Developer Portal**.
2. From the left sidebar, go to **Configure** → **Integrations**.

   ![Figure 1: Harness Integrations in the integration type picker](https://1305598861-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1bzrz9ybUGCcYdvS4u0z%2Fuploads%2Fgit-blob-2e51bdd611208ede81a2937033411f85a3115c17%2Fharness-integrations1.png?alt=media)
3. Click **+ New Integration**, and then choose **Harness Integrations**.

### 2. Enter the integration details

1. In the **Integration Details** section, select **Harness Code Repository** from the **Choose Integration** dropdown.

   ![Figure 2: Integration Details with Harness Code Repository selected](https://1305598861-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1bzrz9ybUGCcYdvS4u0z%2Fuploads%2Fgit-blob-1df1d3fc835635846015c1fb2452ee5ce56c7250%2Fhcr-int-details.png?alt=media)
2. Enter a name in the **Integration Name** field. For example, `DocTest HCR`. This name appears on the integration card on the **Integrations** page.

### 3. Set the integration scope

In the **Integration Scope** section, choose one of the following:

* **All scopes** - Repository and AI asset data across all scopes in the account is imported.
* **Particular organizations and projects** - Repository and AI asset data is imported only from the scopes you select. A **Scopes** picker appears where you can search for and select organizations and projects.

  ![Figure 3: Integration Scope with All scopes and Particular organizations and projects](https://1305598861-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1bzrz9ybUGCcYdvS4u0z%2Fuploads%2Fgit-blob-4f48b4fb046b2dcc90b975f7a050432bd762c1cc%2Fhcr-int-scope.png?alt=media)

Repositories outside the selected scopes do not appear on the [Discovered tab](#discovered-tab).

### 4. Configure mapping and correlation

The **Mapping & Correlation** section defines how HCR entities are mapped and correlated to your catalog. It has two entity types, **Repository Entity** and **AI Assets Entity**, each with its own toggle.

#### Repository entity

The Repository Entity mapping imports Harness Code repositories as catalog entities.

1. Ensure the **Repository Entity** toggle is enabled.

   ![Figure 4: Mapping & Correlation with the Repository Entity and AI Assets Entity toggles](https://1305598861-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1bzrz9ybUGCcYdvS4u0z%2Fuploads%2Fgit-blob-189bff952004bea4d0edf92394bc42af99f20f57%2Fhcr-int-mapping.png?alt=media)
2. Under **Entity Registration Behavior**, choose how repositories enter the catalog:
   * **Register & Merge** *(Default)* - Creates new entities, and updates existing ones when a match is found.
   * **Register** - Always creates new entities.
   * **Merge** - Only links to existing entities. Matching entities are recommended, but you can choose another.
3. Choose the **Kind** and **Type**. By default, they are `Component` and `service`.
4. Under **Correlation Mapping**, review how IDP matches a repository to a catalog entity.

For example, the **Ingested Data Path** `metadata.integration_properties.HarnessCode.name` can be equal to the **Catalog YAML Path** `name`.

#### AI assets entity

The AI Assets Entity mapping discovers AI assets such as plugins, skills, agents, and commands in your Harness Code repositories, and registers them in the catalog under the `AIAsset` kind.

1. Enable the **AI Assets Entity** toggle.

   ![Figure 5: AI Assets Entity configuration](https://1305598861-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1bzrz9ybUGCcYdvS4u0z%2Fuploads%2Fgit-blob-e32e6353491834ab1e4b5b917f7e49cd73f7384b%2Fhcr-ai-assets-entity.png?alt=media)
2. Choose the **Type** for the registered entities, if you need to change it.

AI assets support only the **Register** option. They don't support **Merge** or **Register & Merge**, so each discovered AI asset creates a new catalog entity.

The AI asset types are the same as in the GitHub integration. Go to [AI assets entity](https://developer.harness.io/internal-developer-portal/use-idp/software-catalog/create-entity/catalog-discovery/integrations/github.md#ai-assets-entity) for the list of types.

### 5. Confirm

Click **Confirm & Enable** to create the integration.

IDP syncs with HCR about once every hour. Discovered repositories and AI assets appear on the [Discovered tab](#discovered-tab) after the first sync.

***

## Discover and import Harness Code entities

Open the integration from the **Integrations** page to work with the **Discovered** and **Imported** tabs. Use the **Repository** and **AI Assets** chips below the tabs to switch between entity types.

### Discovered tab

The **Discovered** tab lists HCR entities that the integration found in the selected scopes and that are not yet imported. The **Last Sync** time at the top right informs you when IDP last synced with HCR. To sync before the next scheduled sync, click **Sync**.

![Figure 6: Discovered tab with Harness Code repositories and the register/merge recommendations](https://1305598861-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1bzrz9ybUGCcYdvS4u0z%2Fuploads%2Fgit-blob-14f90dcc07481649fe3858fd87c76dd6842d687d%2Fhcr-discovered-tab.png?alt=media)

{% hint style="info" %}
**VISIBILITY DEPENDS ON SCOPE ACCESS**

The **Discovered** tab shows entities only if you have view access to code repositories in a scope. If you do not have view access at the scope that holds a repository, its repository and AI asset entities do not appear on the tab. Different users might see different lists. Go to [Access control](#access-control).
{% endhint %}

| Column                  | Description                                                                                                           |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------- |
| **Harness Code Entity** | The repository or AI asset name. Select the column header to sort. Use the search box to filter by name.              |
| **Action**              | **Register** or **Merge**. **Merge** is marked **Recommended** when a catalog entity matches the correlation mapping. |
| **Kind**                | The catalog entity kind configured on the integration, for example `component`.                                       |
| **Detected On**         | The date and time the integration first detected the entity. Select the column header to sort.                        |

For each entity, choose one of the following actions:

* **Register** - Creates a new catalog entity populated with the HCR metadata.
* **Merge** - Links the entity to an existing catalog entity. The **Select an entity to merge with** dropdown displays the recommended entity first. Each entity in the dropdown displays its ID, project, and organization, so you can choose a different one.

![Figure 7: The Select an entity to merge with dropdown with the recommended entity and other catalog entities](https://1305598861-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1bzrz9ybUGCcYdvS4u0z%2Fuploads%2Fgit-blob-d9be1684facca745a0c2307a018de094f83bcf97%2Fhcr-merge-dropdown.png?alt=media)

{% hint style="info" %}
**BULK IMPORT AND AUTO IMPORT OPTIONS**

* **Bulk Import** - Select entities individually using the checkboxes, or use the floating widget at the bottom of the page. Open the **Select entities** dropdown to choose entities by action type, and then click **Import selected entities**.
* **Auto Import** - Select **Auto-import future discovered entities** at the top right of the Discovered tab to import entities that IDP discovers from now on, without manual review. Auto import does not apply to entities that are already on the Discovered tab. You can change the preference at any time.
  {% endhint %}

### Imported tab

The **Imported** tab displays HCR entities that you have brought into the catalog.

![Figure 8: Imported tab with Harness Code repositories merged into catalog entities](https://1305598861-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1bzrz9ybUGCcYdvS4u0z%2Fuploads%2Fgit-blob-50ee03c98cfe89aeb7f1dc23fd88fe9d8fef5fd9%2Fhcr-imported-tab.png?alt=media)

| Column                  | Description                                                                                       |
| ----------------------- | ------------------------------------------------------------------------------------------------- |
| **Harness Code Entity** | The repository or AI asset name, and its import status, for example **Merged** or **Registered**. |
| **Entity**              | The linked IDP catalog entity and its ID. Select the column header to sort.                       |
| **Kind**                | The catalog entity kind.                                                                          |
| **Type**                | The catalog entity type.                                                                          |
| **Scope**               | The Harness project and organization of the catalog entity.                                       |
| **Imported At**         | The date and time the entity was imported.                                                        |

{% hint style="warning" %}
**UNLINK AN IMPORTED ENTITY**

To stop syncing a specific entity without deleting the catalog entity, open the three-dot menu on the row, and then select **Unlink**. The entity returns to the **Discovered** tab, and the catalog entity keeps its existing data.
{% endhint %}

***

## View Harness Code data in the catalog

Imported repositories are standard catalog entities, registered by default with the `Component` kind and the `service` type. Imported AI assets are registered with the `AIAsset` kind.

Developers view HCR data on the **Source Code** tab of the entity. The tab requires a one-time [layout configuration](#layout-for-the-source-code-tab).

### Layout for the Source Code tab

HCR uses the same `SourceControlTab` component as the GitHub and Bitbucket Cloud integrations. Set its `sourceControlType` prop to `HarnessCode` to display Harness Code data.

1. From the left sidebar of IDP, go to **Configure** → **Layout** → **Catalog Entities**.
2. Select the **Entity Kind** (for example, `component`) and the **Entity Type** (for example, `service`) that match your imported HCR entities, and then select **Edit Layout**.
3. In the YAML editor, add the following definition inside the `tabs` block:

   ```yaml
       - name: Source Code
         path: /source-code
         title: Source Code
         contents:
           - component: SourceControlTab
             specs:
               props:
                 sourceControlType: HarnessCode
               gridProps:
                 md: 12
   ```

   If the layout already has a **Source Code** tab, add the `specs` block to the existing `SourceControlTab` component instead of adding a second tab.

   ![Figure 9: Entity layout with the Source Code tab set to sourceControlType HarnessCode](https://1305598861-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1bzrz9ybUGCcYdvS4u0z%2Fuploads%2Fgit-blob-0ec0e56b4a54ccbaf9b8f51172102fc04b99268d%2Fhcr-layout-config.png?alt=media)
4. Click **Save**.

The **Source Code** tab now appears on every entity detail page of the selected kind and type.

### Source code tab

The **Source Code** tab displays the repository details and the pull requests of the Harness Code repository linked to the entity.

![Figure 10: Source Code tab with the HCR repository details and the pull request list](https://1305598861-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1bzrz9ybUGCcYdvS4u0z%2Fuploads%2Fgit-blob-01e30d2927b72b54d17d63813d97395122e91027%2Fhcr-source-code-tab.png?alt=media)

The tab has the following sections:

* **Integration Sources** - When more than one integration is linked to the entity, the dropdown at the top right lists each one. Select the integration whose data you want to view.
* **Source Control Management** - The open, closed, and merged pull request counts, plus the repository details: the latest Git tag, its publish date, the primary language, etc. The counts come from the repository metadata in the entity's [ingested properties](#ingested-properties). The language is empty when the repository has no language set in HCR.
* **PRs** - The list of pull requests of the repository, fetched live from HCR when the developer opens the tab.

{% hint style="info" %}
**HOW THE PULL REQUEST LIST WORKS**

* The list includes open, closed, and merged pull requests together, sorted by the most recently updated first. It does not filter by state.
* The list shows all pull requests of the repository. Unlike the GitHub integration, it has no 30-day window.
* The list is paginated. Use the page controls to move between pages, and select the number of pull requests per page.
* IDP fetches pull requests with your own token, so you see only the pull requests that Harness Code allows you to view. Go to [Access control](#access-control).
  {% endhint %}

### Ingested properties

To inspect the raw data ingested from HCR, open the entity, click **View YAML**, and then select **Ingested Properties** in the Entity Inspector.

![Figure 11: Entity Inspector with the HarnessCode ingested properties](https://1305598861-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1bzrz9ybUGCcYdvS4u0z%2Fuploads%2Fgit-blob-28e49460b4d613ae99028837b06a24cd5aaea8c0%2Fhcr-ingested-properties.png?alt=media)

Values live under `metadata.integration_properties.HarnessCode`. For repository entities, they include the repository name, the open, closed, merged, and total pull request counts, the HCR tags (custom key-value metadata), the latest Git tag and its publish date, the language, and the repository visibility.

Ingested properties are read-only on the entity. To change a value, change it in HCR, and the next sync updates the entity.

***

## Access control

IDP shows Harness Code data only to users who can view code repositories in the scope that holds the repository (account, organization, or project). This rule applies as follows:

* **Discovered and Imported tabs** - You see a repository and its AI assets only if you have view access in the scope that holds them.
* **Pull requests on the Source Code tab** - IDP fetches pull requests with your own token, so Harness Code blocks any pull requests you aren't allowed to view.
* **Catalog entity and ingested properties** - After an IDP Admin imports a repository, everyone who can view the catalog entity can see its metadata. Importing shares the repository's metadata, not the repository itself.

{% hint style="warning" %}
**ACCESS IS CHECKED AT THE SCOPE LEVEL ONLY**

IDP checks view access to code repositories in the scope that holds the repository (account, organization, or project), not on individual repositories.

* **Repositories:** If you have access to a repository but not to its scope, you do not see it on the **Discovered** or **Imported** tab.
* **Imported metadata:** When an admin imports a repository, they share its metadata, not the repository itself.
* **PRs:** IDP fetches PRs with your own token, so Harness Code blocks any PRs you are not allowed to view.

To give a user access, grant view access to code repositories in that scope through a user group and role. Go to [Platform access control](https://developer.harness.io/harness-platform/use-harness-platform/platform-access-control) for details.
{% endhint %}

***

## Manage the Harness Code Repository integration

### Edit the integration

To change the name, the scope, or the mapping and correlation settings, go to **Integrations**, open your Harness Code Repository integration with the **View** button, and then click **Configuration**. Update the fields, and then confirm.

### Suspend the integration

Suspending stops discovery and sync while it keeps the configuration and the imported entities.

1. Go to **Integrations**, and then open your Harness Code Repository integration with the **View** button.
2. Click **Configuration**.
3. In the **Danger Zone** section, click **Suspend**, and then confirm the action.

To resume, reopen the integration, go to **Configuration**, and click **Confirm & Enable**.

{% hint style="info" %}
You cannot delete a Harness Code Repository integration from the IDP UI. To stop it, you may suspend it.
{% endhint %}

***

## Troubleshooting

Select any issue below to expand it and view the cause and fix.

<details>

<summary>Harness Code Repository is missing from the Choose Integration dropdown</summary>

The account already has a Harness Code Repository integration, or the `IDP_CODE_INTEGRATIONS` feature flag is not enabled. Open the existing integration from the **Integrations** page, or contact [Harness Support](https://www.harness.io/support) to enable the feature flag. Also confirm that you are creating the integration at the account scope.

</details>

<details>

<summary>A new repository does not appear on the Discovered tab</summary>

IDP syncs with HCR about once every hour. Click **Sync** at the top right of the integration to sync now. Also confirm that the repository is inside the scopes you selected in **Integration Scope**.

</details>

<details>

<summary>A user cannot see a repository or its pull requests that other users can see</summary>

The user does not have view access to code repositories in the scope that holds the repository. IDP checks access at the scope level only, so a repository-level permission in HCR is not enough. Grant the user view access in that scope. Pull requests also depend on the user's own access in Harness Code. Go to [Access control](#access-control).

</details>

<details>

<summary>The Source Code tab displays no Harness Code data</summary>

Check that the layout for the entity's kind and type has a `SourceControlTab` with `sourceControlType: HarnessCode`, and that the entity is imported on the **Imported** tab. If the entity has more than one integration source, select the HCR integration in the **Integration Sources** dropdown.

</details>

{% @harness-feedback/feedback %}
