Using Sonarqube 6.2, I have setup a permissions template with a Project Key Pattern: 'generic\.*'. That permssions template has a group that contains a user. When I run sonarscan on a new project with sonar.projectKey=generic.org.sonarqube:parent2, the user can't see the project till I 'Apply Permissions Template' to that new project. My understanding was that the matching permissions template should be applied automatically on new project creation without an Admin user being required to apply the template manually through the UI ?

2

There are 2 best solutions below

4
On

As indicated in the UI when creating a Permission Template: the Project Key Pattern should be a valid regular expression.

So your problem seems to simply boil down to regex definition: generic.org.sonarqube:parent2 does not fully match withgeneric\.* (see online regex tester). You miss a dot before that trailing * in order to match 0 or more characters at the end.

All in all: try with generic\..* as regex.

0
On

Use sonar.projectName=generic.org.sonarqube:parent2. Otherwise, the permission template won't be applied with the first analysis creation.