Scan C# projects through Jenkinns CI, problem quality profile automation

Dear Sir or Madam,
I am writing to enquire about the following issue:

We have developed projects using C#, which were managed by IC. Nowadays, we are integrating SonarQube in Jenkins. To be honest, it works but we cannot choose a quality profile for each project automatically.
Each pipeline applies different projects and each project has its own C# quality profile.
We know that the function can be only done using a graphic interface from the user but we need an alternative to be able to do this in an automatic revision generated by IC (Jenkins).
We are using the version “Community 8.7 (build 41497)”

I look foward to hearing from you,

Greetings from Argentina,

Diego.

Hi @djpipa88 ,

Welcome to SonarSource Community! :sonarsource:

Ideally, you should set the quality profile from the SonarQube UI by navigating from the project’s dashboard > Project Settings > Quality Profiles:

You should set the quality profile in the SonarQube UI so you don’t need to change it or set it from your IC/Jenkins. Each project can have its own C# quality profile.

If you need to set the quality profile on a new project that you have just created or scanned for the first time or you prefer to not use the SonarQube UI, then you can use the web API endpoints,

From the documentation, look for “POST api/qualityprofiles/add_project” and you’ll see the query parameters you need. In your IC, you can add a curl script that does the following, for example:

curl -u 2cd08caeb6c50177d0e7d9f9eaf3eb22fb93e289: --request POST 'https://<INSERT_SONARQUBE_HOSTNAME>/api/qualityprofiles/add_project?language=swift&qualityProfile=Sonar%20way&project=provision-test' 

Joe

Hello Joe, i appreciate your answer!

I have to tell you that the command to select a profile did not work but it gave us a great help: instead of using it, we decided to choose the “set deafult” to set the profile that we are going to use to each Jenkins’ performance. Do you know if there is a better option?

Besides, i would like to know if the SonarQube has the option of comparing codes when they are being analyzed. I mean, we want the SonarQube to analyze the component lines which have been modified comparing two files with the same name (productive version, modified version). Another option is that we can add exceptions in the Jenkins pipelines to avoid including specified files during the scanning, for example: file1.cs; file2.cs)

I look forward your response.

Thank you very much!

Diego.

Hi @diego ,

I’m not sure where that is. Can you post a screenshot?

Yes, what you are describing is most likely Branch Analysis, which is available in Developer Edition, not Community Edition. This will achieve what you want and allow you to do Pull Request Analysis. Community Edition will allow you to analyze only one branch at a time.

Regards,
Joe

A post was split to a new topic: How lines are counted in Developer Edition