Feature-Request: SonarQube-PermissionTemplates - Multi-Project-Key-Pattern handling

Feature Request:

  • on SonarQube-PermissionTemplates, you can define project key patterns to automatically apply templates to new projects, whose project key fits the project key pattern
  • when multiple project keys fit the project key pattern, you get an error while creating the project and can not proceed, until you clear the conflict in the permission templates
  • my feature-request: project key patterns should not generate conflicts, but be evaluated by their fit in %. E.g.,
    • I have one template (Template1) with project key pattern Test_.* and another template (Template2) with project key pattern Test_RealTest_.*.
    • I create a new project out of any DevOps platform, so the project key gets autogenerated like this Test_RealTest_Project1.
    • I would like the Template2 to be selected for autoapply on the new project, since the project key pattern of Template2 fits better with the project key than Template1

This feature request results in us having multiple projects, which require different templates, but have very similar project keys.

Hey Kevin.

I’m curious to know how you think SonarQube should pick which pattern matches it “best” – based on the length of the RegEx? Some other specificity score?

Hi Colin,

thanks for your answer.
In my example, comparing the length of the Regex and choosing the longer one would be enough.
But i think, it would be best for others to use a score to determine how well a regex fits a string. I don’t have any specific idea for the specificity score.

For me, comparing the length would be enough.

By the way, we have a workaround to extend one project key pattern as a regex, which can not conflict with the other project key pattern.

Pattern1: "Test1_Test_."
Pattern2: "Test1_(?!Test)_.

It works, but it is time-consuming to maintain. You must always ensure, that there are no multiple regex expressions, which fit one project key.