Description:
We’ve noticed that when creating SonarQube projects via the REST API (/api/projects/create), the global default main branch setting (sonar.projectCreation.mainBranchName) is not applied.
Currently:
-
UI-created projects: Respect this setting.
-
API-created projects: Ignore this setting, defaulting to
master. -
DevOps platform imports: Also ignore this setting.
Impact:
This behavior causes inconsistency between UI-created and API-created projects. In environments where projects are provisioned automatically via CI/CD pipelines, the main branch defaults to master regardless of organizational conventions (e.g., main), and there is no API mechanism to override it.
This has several implications:
-
Teams must manually run a first analysis on the intended main branch to correct it.
-
Automated provisioning pipelines cannot enforce branch naming consistency.
-
Documentation may mislead users into expecting the global default to apply in API workflows.
Supporting Documentation:
“If you add your project manually, your main branch defaults to the name
master.”
- Observed behavior: Projects created via
/api/projects/createignoresonar.projectCreation.mainBranchNameand default tomaster.
Requested Enhancement / Question:
-
Can the API provide an option to specify the main branch at project creation?
-
Alternatively, can the global default
sonar.projectCreation.mainBranchNamebe applied to API-created projects, just like UI-created projects?
Environment / Version:
-
SonarQube Server Version: Developer Edition v2025.5
-
API:
/api/projects/create
Additional Notes:
This limitation currently requires extra manual steps or first-analysis workarounds to ensure consistent main branch naming across automated projects.