Is there a way to define which quality profile will be associated when a new project is being created?

Hello

SonarQube 6.7.2 Developer Edition

Is there a way to define which quality profile will be associated when a new project is being created?

I am using Jenkins and would like a way to add a parameter to define which quality profile the project uses.

Example:
If I have multiple Java quality profiles defined (JavaProfile1, JavaProfile2, JavaProfile3).

Is there a sonar properties parameter I can set, to define which profile to use for new projects?

Thanks
Jason

Hi Jason,

Negative. If you don’t provision the project then the default Quality Profile will apply on first analysis. If you wish to specify a specific Quality Profile ahead of time, then the right approach is to first provision the project on SonarQube side. Note that such provisioning can also be scripted (if needed), using SonarQube WebAPI (documentation embedded in server).

Thanks Nicolas, I will look into that.

We are experiencing the same issue as well. We are using the Maven Sonar scanner and since the removal / deprecation of sonar.language, this is becoming a greater issue.

Is this still the current recommendation? We do not want users having to log into SonarQube and pre-provision their projects. Likewise, executing Maven scan from a developers machine will not allow “scripting”.

Short of branching the Maven SonarScanner code and making our own custom build, I do not see a viable solution.

Hi Nicolas,

I am using sonar webapi to associate a project with a quality profile but not able to do it. On every run of sonnar-scanner it is associating default quality profile. Below is the code snippet.
curl -k -X POST --insecure -H “X-Auth-Token:XXX” -d ‘language=py’ -d ‘name=test_profile’ -d “project=test_1.0” https://sonartest.xxx.com/api/qualityprofiles/add_project

I am not sure what i am doing wrong. I have administrative access and followed the webapi of Version 6.7.3 (build 38370)

Hi @Shashi_Ujjwal,

It looks like you’re passing your auth token as “X-Auth-Token:XXX”? This should help: https://docs.sonarqube.org/latest/extend/web-api/

Also, it’s incumbent upon me to mention that the current LTS is 7.9.2, and the latest version is 8.1 (just any minute now). You should upgrade at your earliest convenience.

 
Ann

Thanks @ganncamp . It worked !