Search code examples
sonarqubesonarqube-scansonarqube5.1

Apply custom permission template automatically for sonarqube new project report using sonar-runner


How to configure sonar.projectKey under sonar-project.properties so that we can get apply custom permission template for new project report automatically. Does anyone try that? I was trying all type of combination with project key in sonarqube permission template and sonar-runner properties file. But couldn't achieve the result.

Does sonar permission template really support this from sonar-runner.

Below are screenshot attached to the link for my use case:

I have created mfg-desktop permission template and there is also present a default template provided by sonar

When I checked under project permission, I found that default permission template is getting applied in each time


Solution

  • Create a new permission Template and assign the regex to the Project Key Pattern.

    For example: Regex : (prod)-\w+

    It will apply the template to the new projects created with Project Key starting with 'prod-'. Sonar needs the key of the new projects to 'fully' match the regex of the permission template key. Using * might not work.

    Then link the desired permissions of the users/group on the template. Also make sure the Global Permissions for the users/group are also set appropriately else permissions wont work.

    Additional Info: All projects will still be visible to all users. Make your project 'Private' to make it visible only to the required group. This works on CE v7.6