问题
Our use case for Sonar creates new Sonar projects for each branch of our repository. How do we automatically associate the new branch project with a (non-default) Quality Profile and Quality Gate?
We're running this in a Maven project if that's relevant.
回答1:
We had the same issue, within our company, and the only solution was to use the deprecated attribute sonar.profile
(https://docs.sonarqube.org/display/SONAR/Analysis+Parameters).
Sidenote: Generally there is also a interesting view on how to analyze branches. The general recommendation from sonarSource suggests to only use preview modes for short living branches. As a fact bitbucket-plugins with a richer featureset than just commenting issues, sadly need branch based analysis.
https://jira.sonarsource.com/browse/SONAR-5370 - the property will be removed in 4.5.1 based on the sonar task
回答2:
Use the api/projects/create web service to provision your projects. You can then call api/qualityprofiles/add_project to assign your new project to the proper profiles. (You'll need to have first looked up the profile id's tho with api/qualityprofiles/search.)
来源:https://stackoverflow.com/questions/44530552/automatically-associate-new-sonar-project-with-custom-quality-profile-and-qualit