Sonar property for reference branch

Hi,

no need to create a branch via api, as it is automatically created via sonar.branch.name property
during the analysis.

We use it like that, i.e.
A generic Jenkins pipeline for Maven builds implemented as shared library and driven by
a yaml config file.

The pipeline checks if project already exists using api/projects/search , if not it is created.
https://<yoursonar>/api/projects/create?project=com.foo:foobar&name=foobar
Normally project is created automatically, it’s only because of the reference branch / new code setting.

If yaml has sonarMainBranch: xxx the main branch is renamed, otherwise default = master.
https://<yoursonar>/api/project_branches/rename?project=com.foo:foobar&name=xxx
It’s also checked if this branch exists in Git !

Main branch is set as reference branch for all branches.
https://<yoursonar>/api/new_code_periods/set?project=com.foo:foobar&type=REFERENCE_BRANCH&value=xxx

Finally you set new code for the main branch to previous version, as it can not reference itself.
https://<yoursonar>/api/new_code_periods/set?project=com.foo:foobar&branch=xxx&type=PREVIOUS_VERSION

This will result in

any new branch will automatically use the reference branch project setting

Gilbert