Permission Templates can't be used with custom Project Key

Hi,

I have the group “BACKEND” that represents permission for backend teams with full permissions on their sonar projects.

All of their projectsproject key preffix - “backend:”.

I created the template with regexp for project key - “backend.*” and specified required permissions for “BACKEND” group.

During configuration of a new project from Github organization I select a required project and it’s created in SonarCloud BUT it’s always created with default key - _. This key doesn’t match with my key pattern from my custom permission template. As a result a new project is created with permission from ‘Default Template’.

What doesn’t work:

  • Updating key on a newly created project doesn’t have affect.
  • Putting sonar-project.properties in the root folder with value: sonar.projectKey=backend:test-sonarqube-repo doesn’t have affect as well.
  • ‘Analyze new project’ wizard doesn’t support to specify a custom project key to override default one.

Is it possible to use ‘Permission Templates’ with custom ‘Project Key’?


As a suggestion it would be great to have for example a new property: sonar.projectKeyPreffix that you can specify in ‘Analyze new project’ wizard or put in sonar-project.properties as a static value.
It would be very helpful especially for projects where ‘Project Key’ is defined dynamically, like in all our java based projects: property("sonar.projectKey", "${project.group}:${rootProject.name}").

Hi Mykhailo,

Thanks for the question and your patience. The permissions template is applied only at the project creation (Permissions Templates), and if the project key doesn’t match, the template will not apply. However, it is possible to apply the template after creation in the Projects Management section (Applying permission templates to subsets of groups).

You mentioned that the SonarCloud project is created with the default key “_”
Is the key overridden intentionally before the project creation, or is it not expected?

Thanks,
Radim