Uploading the Sonarlint results to SonarQube[Cloud Server]



Before getting into this tutorial please read the information about the Sonarlint by clicking on this link.
Sonarlint helps the developer analyzes the code quality on the fly and displays the scan results. Now the Question is, would it be possible to push these results to SonarQube.

What is SonarQube??

SonarQube provides the capability of displaying the results in a Dashboard. And it also helps to configure the Quality Gate to improve the Code Quality. If we want to publish the results from Sonarlint to SonarQube the code does not require any compilation. Once the code scans are done we can push the results directly into SonarQube.

Bind the Sonarlint to SonarQube:

Right click on the project in Eclipse Select Sonarlint->Bind to SonarQube to SonarCloud option as mentioned below:

Binding Sonarlint to SonarQube or SonarCloud

Binding Sonarlint to SonarQube or SonarCloud

Select the connection type as SonarCloud and click on Next button.

SonarCloud Connection

SonarCloud Connection

Provide the Token generated from SonarCloud Server in the mentioned dialog box.

GenerateToken

GenerateToken

Access the SonarCloud server URL https://sonarcloud.io/projects as mentioned below.
Click on Analyze new project button and

SonarCloudServer-Analyze New Projects

SonarCloudServer-Analyze New Projects

Provide all the required information and click onSet Up button.

AnalyzeProjects -SonarCloudServer

AnalyzeProjects -SonarCloudServer

Click on the Generate button for generating new token.

GenerateToken

GenerateToken

Run the analysis on your project.

Sonar Cloud - Run Analysis

Sonar Cloud – Run Analysis

Execute the Command from the Command line to push results of Sonarlint to the SonarQube Cloud.

mvn sonar:sonar \
-Dsonar.projectKey=SonarlintScanResults \
-Dsonar.organization=totalqa \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=5a24ca7f4b56ccabd93da62f36915f08f8517482

Sonarlint-Scan Results

Sonarlint-Scan Results

Conclusion

Results generated from Sonarlint are pushed into SonarQube Server Successfully.

Leave a Reply

Your email address will not be published. Required fields are marked *