sonarcloud is an online code analysis service completely free for public projects. It supports many of the popular languages like C#, Javascript, Java and many more. The best part is it has inbuilt integration with Azure DevOps, Github and BitBucket.
In this article we will explore sonarcloud integration with Azure DevOps Pipelines. mn
To configure your project with sonarcloud you need a active subscription, you can get started from here.
Once you are logged in, you may need to create an organization first by clicking top + icon on the right.
Once you have clicked on the + icon, you get the screen to create organization. You can either import organization details from Github(if you used Github login) or manually create the organization, select create manually for the time being.
Next it will ask you to pick a plan, if you have a private project then you may need to opt for paid plan. To get started lets pick free plan as it offers free code analysis for public projects.
and click on Create Organization.
You get the dashboard for your organization, click on analyse a new Project.
Fill in the project details and select Public, click on Setup.
Now go back to Azure DevOps organization and create a Service Connection for sonarcloud. You can simply click on link to generate token and verify the connection.
Before you can use sonarcloud in your pipeline, you will need to install an extension from marketplace in you Azure DevOps organization from that you can get here.
Once you have installed the extension to your Azure DevOps organization, it makes couple of task available in pipeline to be added.
Add Prepare Analysis Configuration task in your pipeline.
After that you will need add other two task for analysis and publishing the results. And click on Run to queue the build.
After running the build, you shall be able to see the analysis on sonarcloud Project dashboard.
Good one Ashish.
I had done this few weeks back … if u see code coverage it comes as 0% as of now. I tried to capture this with some script but could not succeed … will give another attempt next week.
It will be good to explore this option in coming days.
Rightly said, since i had not unit test on my demo code so its zero coverage.
great stuff.
I i want to publish the overview in Azure DevOps pipelines, how do I do that?