Perform an analyse without push result on SonarQube Server

On a gitlab job, I want to perform a analyse without push the result on the SonarQube server.
The goal is to have only the result in local to do comparaison with my actual analyse on SonarQube server.

I wanted to know if it’s possible to not push those result.

I use maven sonar analyse with a 8.5.1 SonarQube version.

Hi @aehanno,

I don’t believe this is possible since each analysis requires connection to a SonarQube server: you won’t be able to see the analysis unless it’s uploaded to SonarQube. One goal of using SonarQube is to utilize the UI to understand your analysis.

Is this how you want to analyze?

  1. Sonar analysis 1 finish, upload to SonarQube
  2. Sonar analysis 2 finish, don’t upload to SonarQube (you can just kill the analysis manaully right before it finishes if you want to stop it (e.g. stop build))
  3. Compare Sonar analysis 2 to Sonar analysis 1

How do you compare that? With just the logs of Sonar analysis 2 to the logs of Sonar analysis 1?

Joe

Hello @Joe ,

“I don’t believe this is possible since each analysis requires connection to a SonarQube server: you won’t be able to see the analysis unless it’s uploaded to SonarQube. One goal of using SonarQube is to utilize the UI to understand your analysis.”

I don’t understand this, since when I run the scanner, it does the analysis and places the results in directory .scannerwork inside the project directory, which is defined by an analysis parameter, sonar.working.directory. So, I could extract the results from there and interpret them as the sonarqube does, couldn’t I? I mean, if I collected these results over the time, I would get meaningful information.

Yes, you can extract the results but it is not human-readable, so it won’t help. You would need to submit this analysis information to SonarQube and the Sonar scanner handles that automatically, it’s already part of the scanner process.

Why do you want to collect results over time? Why not just let Sonar scanner submit it to SonarQube?

Hello again,

Thanks for replying so briefly!

Essentially, what I intend to do is to only use the Sonar Scanner without connecting it to the SonarQube. I’m asking these as the company I work for has now other needs, and want to be able to apply SonarQube to a new tool designed by us, to evaluate commits from all developers of a project and extract metrics from the SonarQube analysis, that aggregated with other information extracted by tools such as Jira would have meaning for us. The problem with using the Sonar Scanner is that it publishes the results to SonarQube, and this is unnecessary as we are not interested in what is presented there, because we will have our own UI.

I tried some of the analysis parameters to see if they acted as I intended and turned off the publishing of the results, but without success. I think that this could easily be implemented as a new analysis parameter, to disable or enable (the default could be enable), as I already posted here New Analysis Parameter.

Hello @mma.coelho ,

Thank you for explaining your purpose, I understand better now. You cannot disconnect usage from SonarQube, but once you submit the analysis to SonarQube, you can use the Web API to pull the metrics you want, compile reports, collect information, etc. using this REST API. Thus, you can ignore usage of SonarQube UI and just pull the data you need via web API.

Thank you also for creating the Product-Manager-for-a-Day thread!