Sonarqube 8.4.1 branch analysis, definition of new ?!

Think i’ve found a working hack.

  1. api/projects/search?projects to check if project already exists

  2. api/projects/create if it doesn’t exist

  3. api/new_code_periods/set?project=$projectkey&type=REFERENCE_BRANCH&value=master

  4. api/new_code_periods/set?project=$projectkey&branch=master&type=PREVIOUS_VERSION

  5. run Sonarqube analysis

Thought 3. would not be possible if project is newly created in 2. ,but it is.
Should also be almost safe for parallel builds and scans of the same project !?

After all this is no clean solution, hope it gets polished with the next versions !!

Out of curiousity
What were the reasons to break with the use of the sonar.branch.target property ??