restsonarqubesonarqube-scan

How to associate a project with a quality profile in Sonarqube


I am using sonar webapi to associate a project with a quality profile but not able to do it. On every run of sonar-scanner it is associating default quality profile.

This is the code snippet:

curl -k -X POST --insecure -H “X-Auth-Token:XXX” -d "language=py" -d "qualityProfile=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)


Solution

  • Finally got some help from Soanrqube community. I need to remove X-Auth-Token from code. It should be something like this

    curl -u ur_token: -X POST -d language=py -d qualityProfile=test_profile -d projectKey=${params.ProjectName} https://sonar-url.com/api/qualityprofiles/add_project