When pushing analysis results, we get a series of error messages, followed by:
Caused by: Project was never analyzed. A regular analysis is required before a branch analysis
I found that this is caused by analyzing a branch for a project that hasn’t been analyzed before. From what I understand, there are two ways to solve this: create the project manually before analyzing or analyze the master/main branch first.
Analyzing the master branch first is problematic, since it’s protected and can only be changed through completing a PR. The yaml build script (we’re using azure devops) is part of the same repository and subject to this policy. Changing the build definition to include sonarqube analysis can therefor only be done on a branch and a succesful build is required as part of the PR.
Manually creating the project beforehand is impractical, since people that create new projects in azure devops are not the same that configure SonarQube and in some cases projects and builds are created or changed using scripts that don’t have hooks to SonarQube.
So I would like to suggest to allow provisioning a new project from analyzing a branch, in a similar way to what happens when creating a new project manually (ie. without code analysis results from master).
We’re using SonarQube Enterprise version 7.9.4 (on-premises). While I understand that there are newer versions available, I haven’t found any indication that newer versions act differently on new projects.