Latest
Sonar 1 min read

Analyze Multiple Projects in One Repository with SonarQube

Analyze Multiple Projects in One Repository with SonarQube
Sonar · September 17, 2026

Version note: references describe SonarQube Server 2025.2 behaviour. Check your server, scanner and edition requirements. These examples were not run against a live SonarQube server.

What this guide covers

A repository can contain several applications. Giving each independently maintained application its own SonarQube project makes its issues, coverage and quality-gate result easier to understand.

Before you start

Identify each application’s directory, tests, report path and project key. This example uses two ordinary service directories, services/billing and services/catalog; replace them with your own.

Step 1: Choose one project per application

Create the SonarQube projects and record their unique keys. Decide how shared code is tested and analyzed. Do not accidentally count it differently in every service.

Step 2: Set paths relative to each service

Place a scanner configuration in each service directory, for example:

sonar.sources=src
sonar.tests=test
sonar.javascript.lcov.reportPaths=coverage/lcov.info

Generate that service’s coverage report before scanning it. Paths here are relative to the service root, not the top of the repository.

Step 3: Run each scan from its directory

After installing dependencies and running tests for both services, run:

set -eu
(
  cd services/billing
  test -s coverage/lcov.info
  sonar-scanner -Dsonar.projectKey=shop-billing
)
(
  cd services/catalog
  test -s coverage/lcov.info
  sonar-scanner -Dsonar.projectKey=shop-catalog
)

Use an analysis token with the required project access. Separate project tokens can limit access further.

Step 4: Check shared-code changes

At first, analyze every service on each trusted build. If you later scan only changed services, include services affected by shared-library and build-configuration changes. A file-path filter alone may miss these dependencies.

Check the result

Each SonarQube project should contain only its intended files and current coverage report. Verify that a shared-code change triggers all required analyses before reducing scan frequency.

References

PB
Written by

Parul Bedi

Notes and guides by Parul Bedi.

Up next

Run a Docker Container with Fewer Permissions

Docker September 19, 2026 1 min read
Open post

Conversation

0 comments

No comments yet. Start the conversation below.

Leave a comment

Replying to a comment.
Be kind. Markdown is not supported in comments.