Hi Team,
I’m currently using SonarQube Community Build v25.10.0.114319, deployed as a pod in Kubernetes. I’m trying to integrate SonarQube scanning into my Azure DevOps pipeline, targeting a repository with the release branch set as default.
When the pipeline is triggered, I encounter the following error during the SonarQube Prepare Analysis task:
##[error]12:59:18.742 ERROR Validation of project failed:
o To use the property “sonar.branch.name” and analyze branches, Developer Edition or above is required. See Analysis parameters | Sonar Documentation for more information.
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘ClassRealm{iac}-org.sonar.iac.helm.HelmEvaluator’: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name ‘AnalysisTempFolder’ defined in org.sonar.scanner.analysis.AnalysisTempFolderProvider: Unsatisfied dependency expressed through method ‘provide’ parameter 0: Error creating bean with name ‘DefaultInputProject’ defined in org.sonar.scanner.scan.InputProjectProvider: Failed to instantiate [org.sonar.api.batch.fs.internal.DefaultInputProject]: Factory method ‘provide’ threw exception with message: Validation of project failed:
I also noticed that:
Sometimes the scan works for one repository.
But from the second repository onward, the same error appears.
I tried explicitly setting sonar.branch.name= in the prepare task, but the error still persists.
Could someone please help clarify:
Is there a workaround for scanning non-default branches in the Community Edition?
Why does the error appear inconsistently across repositories?
The linked code is bugged when the repository is not in the same project as the pipeline trying to do the build. $(System.TeamProject) is the pipeline’s project, so getDefaultBranch() will look for the repo in the wrong project.
Although it doesn’t appear to be documented, it looks like the /{project} segment of the ADO API URL for retrieving a repository is optional. This means that the repository can be retrieved using $(Build.Repository.ID) alone, with a URL like https://dev.azure.com/<COLLECTION>/_apis/git/repositories/<REPO GUID>?api-version=7.1.
Otherwise, the project name would have to be extracted from $(Build.Repository.Uri) to be able to construct the appropriate call.