We are currently hosting a SonarQube 8.4.2 server using a developer edition license for branch analysing. Our pipeline consists of Gradle 7.2 using the newest SonarQube plugin for automating our JVM projects.
Our current branching scheme (Git) can be simplified using the following diagram:
We have one main branch called “develop” where our teams are adding features (including bug fixes etc.) using feature branches so nobody works on the main branch directly. It’s our holy grail and every metric there should always be green.
In SonarQube we activated this main branch “develop” as reference for everything else (in every project - currently ~70) and must be changed for every release branch manually - which is fine.
When we are releasing a new version, we create a dedicated release-Branch as seen above. It is used when we have to patch certain bugs but no new features are added ever.
The main branch “develop” and the release branches use the last version as reference for our metrics including quality gate!
This branching scheme worked “okayisch” until now - a new scheme was proposed because of many developers working simultaniously on a release branch when fixing bugs which often led to conflicts when working together on one branch.
The new branching scheme will look like this:
The change is obvious. Normal work on feature branches doesn’t change but when working on a release branch we are going to use specific bugfix / patch branches to circumvent those conflicts happening before.
There is just one problem: When such a patch branch is created our pipeline will run, creating a new SonarQube analysis. But because of the default configuration, that the reference branch of every branch is our main branch “develop”, the analysis is garbage and the reference branch must be changed AFTERWARDS (after the first analysis) to eg. release/1.0 and the analysis must run again.
Thats our problem we’d like to solve. When running an analysis (using Gradle SonarQube plugin and parameters provided) we found no solution to provide the new, alternative reference branch directly in the first analysis without changing everything manually (I call calling the Web API using automation manually as well) and re-running the SonarQube analysis.
The ideal solution would be to provide such a reference branch as parameter (I think that was the now removed “sonar.branch.target”?) or to add an empty branch using the Web API before running the first analysis so there is no need for work AFTERWARDS (changing the reference branch using Web API and re-running the analysis).
I really hope there is one. We are paying good money for this software
If you have a solution, please provide it or get in direct contact with us (me) as I trimmed my expansive describtion to fit in the post.