> 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/ai-dlc-insights/use-ai-dlc-insights/setup/integrations/sonarqube/index.md).

# Connect with SonarQube

{% hint style="info" %}
The SonarQube integration is in beta. To request access, contact [Harness Support](/software-engineering-insights/troubleshooting-and-resources/sei-support.md).
{% endhint %}

[SonarQube](https://docs.sonarsource.com/) is an open-source platform for continuous inspection of code quality. It performs automatic static analysis to detect bugs, code quality issues, and security vulnerabilities.

On initial setup, Harness AIDI backfills up to 6 months of historical code quality findings. When configured, Harness AIDI can ingest and validate SonarQube code quality data.

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

Before you begin, ensure that you have:

* An [SEI Admin role](/software-engineering-insights/use-software-engineering-insights/get-started/rbac.md#sei-admin-account--project-level)
* Access to a SonarQube or SonarQube Cloud account and can generate a SonarQube API token with read access to the required organizations and projects

### Create a SonarQube API token <a href="#create-a-sonarqube-api-token" id="create-a-sonarqube-api-token"></a>

To configure the SonarQube integration, create an API token in SonarQube. The token must be either a **User Token** or a **Global Analysis Token**, and have permission to read organization and project-level analysis data. For [SonarQube Cloud](https://docs.sonarsource.com/sonarqube-cloud/managing-your-account/managing-tokens), tokens are associated with a user and scoped by that user's organization access.

The token must have access to all organizations and projects you want SEI to monitor, and the following required permission:

| Permission | Why it’s required                                                       |
| ---------- | ----------------------------------------------------------------------- |
| **Browse** | Allows SEI to access projects, metrics, issues, and quality gate status |

Harness recommends using a service account user token with **read-only access** and **no expiry or a long-term expiry (1+ year)**. This helps ensure uninterrupted ingestion and avoids issues caused by employee turnover.

SonarQube tokens can also be scoped at the **organization** level. For more information about creating scoped organization tokens, see the [official SonarQube documentation](https://docs.sonarsource.com/sonarqube-cloud/administering-sonarcloud/managing-organization/scoped-organization-tokens).

{% hint style="info" %}
If your SonarQube instance uses an allowlist, ensure that required Harness IP addresses are permitted. For more information, see [Harness Platform IPs](/harness-ai/use-harness-platform/references/allowlist-harness-domains-and-ips.md).
{% endhint %}

### Add the integration <a href="#add-the-integration" id="add-the-integration"></a>

To add the integration:

1. From the SEI navigation menu, click **Account Management**.
2. On the **Integrations** page, select the **Available Integrations** tab.
3. Locate the **SonarQube** integration and click **Add Integration**.
4. In the **Overview** section, provide a name for the integration (for example, `SonarQube Production`) and optionally, add tags.
5. Click **Continue**.
6. Add your SonarQube instance URL (for example, `https://sonarcloud.io`) in the `SonarQube URL` field.
7. Enter your SonarQube API token in the `API Token` field. The token must be a **User Token** or **Global Analysis Token**.
8. Click **Continue**.
9. Optionally, limit ingestion to a specific organization or set of projects by entering a name in the `Organization` field and a project key in the `Project Keys` field.
   * Project keys are case-sensitive.
   * Leave the `Project Keys` field empty to ingest all projects.
10. Click **Continue** to validate the connection.
11. Once validation succeeds, click **Finish**.

### Integration monitoring <a href="#integration-monitoring" id="integration-monitoring"></a>

Once you've configured the integration, you can monitor ingestion activity on the **Monitoring** tab in the SonarQube integration page.

The **Monitoring** tab displays ingestion logs that show the status and execution details of each sync. You can filter logs by **Status**, such as `Success`, `Failed`, `Pending`, or `Scheduled`.

#### Ingestion logs <a href="#ingestion-logs" id="ingestion-logs"></a>

You can use ingestion logs to validate successful syncs and troubleshoot ingestion issues. Each ingestion run includes the following information:

| Column                     | Description                                            |
| -------------------------- | ------------------------------------------------------ |
| **Scan Range Time**        | The time window for which data was retrieved.          |
| **Data Retrieval Process** | The ingestion process used.                            |
| **Task Start Time**        | When the job started.                                  |
| **Status**                 | Execution status (for example, `Success` or `Failed`). |
| **Time to Complete**       | Total runtime for the job.                             |
| **Retries**                | Number of retries before completion.                   |
