0

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.

Kevin Hooke
  • 2,583
  • 2
  • 19
  • 33

1 Answers1

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.

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
  • Is there a way to create a dashboard once and have it point to analysis results for runs against a specific branch? If this is possible then this would be exactly what I'm looking for, as I wouldn't have to create a new dashboard each time a new branch is added? – Kevin Hooke Apr 26 '16 at 18:05
  • @KevinHooke, yes. Maybe my expanded answer will help. – G. Ann - SonarSource Team Apr 26 '16 at 19:31
  • Thanks for the update, but this sounds like what I already have right now, using the sonar.branch value to differentiate each. So if today I have Dashboad1 (for branch1), and I need to add Dasboard2 (for new work in branch2), then I have 2 Jenkins jobs, 1 running analysis against branch1 and reported by Dashboard1, and 1 against brnach2 and reported by Dashboard2. I still have 2 dashboards though. If tomorrow we start work on branch3 then I create another dashboard against this new branch. Is this what you are suggesting? What I would like to do is automate the creation of each dashboard. – Kevin Hooke Apr 26 '16 at 20:16
  • 1
    One of us isn't understanding something @KevinHooke. We should take this up in the Google group: https://groups.google.com/forum/#!forum/sonarqube – G. Ann - SonarSource Team Apr 27 '16 at 11:31
  • Thanks - I'll head over there and post my question. – Kevin Hooke Apr 27 '16 at 16:54
  • @G.Ann-SonarSourceTeam could you please let me know how can I manage dashboards in version 6.3.1? I cannot find "Manage Dashboards". Also, how can I change the given time for a snapshot. I tried to search but no success yet. Thanks in advance! – Jose May 29 '17 at 13:29
  • 1
    @Jose you can't find 'Manage Dashboards' because it no longer exists. Dashboards have been removed – G. Ann - SonarSource Team May 29 '17 at 20:21