Automated creation of new dashboards in SonarQube - sonarqube

Is there a way to automate/script creation of new dashboards in SonarQube, either via the webservice api or some other means?
I have a need to create dashboards per future releases (Dashboard for Release 1, Dashboard for Release 2 etc) where each release is worked on as a Stream in RTC. This would be easier if the analysis was running against trunk, but this is not how the project is currently structured using a branch/stream strategy.
Currently, as we move to a new future release which is being worked on in a future Stream, I need to recreate an analysis job in Jenkins, and create a new Dashboard against that analysis.
The dashboards are configured with the same widgets each time, but pointing to a different analysis project/results.
Is there a way I can automate creation of a new Dashboard? I see there's a GET api/dashboards/show but what I'm looking for is an api to create, or clone from existing dashboard?
We're using SonarQube 5.1.

A project-level dashboard is a template that is filled with each project's data as you navigate to it. You create it once, and it applies to every project automatically.
It sounds to me like you'll be analyzing the branches of a project. As long as you differentiate them by setting a unique sonar.branch value for each one, the rest should just work. Each branch will show up as a unique "project" in SonarQube - with all the same features, navigation, and yes dashboards as every other project.
Note that there are two types of dashboards: global dashboards project dashboards. Correspondingly, there are two types of dashboard widget: global and project.
You can put either type of widget on either type of dashboard, but if you put a project widget on a global dashboard, it will make you configure a project - because it can't just pick up which project it should show from context.
Put it on a project dashboard, though, and it will automatically display data from the current project.
To create a project dashboard in version 5.1.2, first navigate to a project, then More > Manage Dashboards. There, you'll be able to create, configure, and share project-level dashboards with project-level widgets that just automatically show data from the current project context.
EDIT
Note that dashboards were removed in 6.2, so the directions above are only relevant for versions earlier than that.

Related

Sonar analysis & report publishing permissions

Is it possible to restrict the publishing of new analysis on a sonar instance. My use case is I created new instance of sonar with the latest version. There are couple of projects configured with the old version. I want to make sure that no project team use old instance of sonar. At server level, is it possible to stop publishing new report.
Also what customization options sonar server gives for its home page. I want to display a custom message with Sonar 5.6 version
Atul
You seem to have stood up two different instances of SonarQube side by side. In doing so, you impose on your teams the requirement to update their CI configuration to point to the new instance.
You should instead replace the old version with the new one. See the Upgrading docs for details.

How can I view a log of all recent deployments to a specific environment?

I want to know what deployments have recently occurred on my QA environment. It comprises several servers and several projects, so I don't want to go trawling through each environment separately or each project separately.
I tried clicking on the QA environment header on the home page, but it just takes me to the list of all environments - no links/buttons to logs for a specific environment.
Version: Octopus Deploy 2.6.4.951
I use the filtering on the 'Tasks' page. Looks like filtering was introduced in 2.5. https://octopus.com/blog/2.5#organised-task-page-including-filtering
/Octopus/app#/tasks
There are filters for Environment (QA) and 'Task Type' (Deployment). Checking mine just showed me all the deployments to QA and that there is one waiting approval.
I also filter the tasks page, but also have a PowerBI project which queries the API on the below URL:
http://octopus.example.com/api/reporting/deployments/xml?apikey=API-ABCDEFGHIJKLMNOPQRSTUVWXY
This can then set up whatever you want :)

How do I tell Sonar not to store the source code in the database?

I am trying two options.
One is not to store source code
If it is not possible how to delete project from sonar database?
I tried with "sonar.import Sources=false" but this is not working for sonar version 6.1(deprecated after 4.5 version).
If I delete the project,will source code remain in database?
Storage of source code in database can't be disabled because it's used to display data in webapp.
Source code is indeed dropped from db when deleting a project.
This is late, but might be helpful for someone:
Sonar usually cache the project for performance purpose via squid mechanism, then thru queue mechanism it stores the project data in internal h2 database which can be changed to few supported databases, then you will be having advanced options to manipulate data on database(things like fail-over cases can be achieved), not that I know of any way of not to store project data in database.
Unless you configure certain user, default user can be admin to sonar dashboard with password as admin, Login to console and navigate to Administration-> projects->Management, now delete n number of unnecessary projects. Once you do this Sonar dashboard will not be able to show the project again until you re-analyze same project. To make sure this worked,after re-analyzing project click on the project on dashboard and check the version under Activity.
Additional info: If you modify the maven project code, first build the project & then do sonar:sonar for latest modifications to be reflected.
I agree with other answer, elaborating in few lines..

Custom Rules do not get imported when Quality Profile is restored on another SonarQube instance

I am using SonarQube 5.1.2. I have created many custom rules using Rule Templates for quality profiles of both Java (plugin version 3.13.1) and C# (4.3) languages. I wanted to replicate this SonarQube instance onto a new server and hence did a Backup of the quality profiles and performed 'Restore Profile' on the new SonarQube server.
Strangely, all the custom rules are not imported on to the new SonarQube instance. Why is it so? What should I do to import the custom rules onto new SonarQube instance?
You're looking for SONAR-5366
Make it possible to back up and restore customizations of rules, which is not yet implemented, unfortunately.

How to setup dashboard with all projects view/widget?

I have installed a sonar web site, a jenkins web site( CI machine).
While CI server build projects and send info to sonar server as sonar client.
There are lots of projects in my sonar server.
I need a way to setup dashboard with all projects view or widget.
Just like timeline in sonar demo site
But when I configure my own sonar dashboard, I think there are only treemap and list which hava filter. ( with filter I can get analysis of all projects )
How did sonar demo web site do this?
(Sonar 3.6.2 , CentOS 6.4)
Thanks a lot ~
They are using the views plugin to do it, without (paying for) it you won't be able to do it.
Once you get the plugin, create a view with all your projects, use the view's dashboard as your main dashboard (in manage dashboards) and add the following widgets : "SQALE overview", "issues and technical debt", "timeline", "measure filter as donut chart" and "measure filter as treemap".
That's it, cheers.
This is a matter of the Global Dashboard.
Go to Manage Dashboards -> And here you can either select a current dashboard or create a new one. You have the option of adding a treemap with the metrics of your choice. Their "helicopter view" and the other features are all an aspect of the global dashboard feature. You can compare your projects and show the metrics or multiple projects through this.
Ran in the same situation and after search for workarounds , only find the new product
Governance
The Governance product provides the features to gear-up SonarQube from team-grade deployment to enterprise-grade deployment.
http://www.sonarsource.com/products/plugins/governance/
will be able to do that

Resources