5

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.

Mzzzzzz
  • 4,770
  • 7
  • 30
  • 47

2 Answers2

2

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

Simon Schrottner
  • 4,146
  • 1
  • 24
  • 36
  • yes, this is our situation (trying to include Sonar stats with BitBucket pull requests and Bamboo to launch Sonar analysis on commit). I'd be happy to switch to using the preview mode but I don't see a way to do that with the existing plugins as you say. – Mzzzzzz Jun 14 '17 at 13:51
  • 1
    something on the side, i dont know, how many builds you plan to trigger, but as code analysis may take some time, you probably want to trigger it by hand with https://marketplace.atlassian.com/plugins/se.bjurr.prnfs.pull-request-notifier-for-stash/server/overview - we only trigger the "Feature builds" on "Open, Reopen, and by trigger button" - can save you some jenkins resources :D – Simon Schrottner Jun 14 '17 at 13:56
0

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.)

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
  • 5
    just an imho: that process i find somehow strange, before i set a property and sonarqube took care of - now i have to do 3 api calls to manage that beforehand, but the discussion in the implementation ticket is already pointing that out, i just wanted to note that. – Simon Schrottner Jun 14 '17 at 12:01