Sonar Plugin Development - Create a global metric

丶灬走出姿态 提交于 2020-01-03 02:30:13

问题


I'm trying to create a custom sonar plugin that consists of a widget on the global dashboard.

I want this to display a "global" metric. So for example, a metric showing the number of lines across all projects.

Is this possible, if so how can I go about this? I can only find example projects that run project specific metrics. They output them in the ruby template like this: format_measure('random'). I am guessing this format measure only works in project context.

The documentation is extremely light on this whole process. So if anyone knows of any good documentation or guides that would also be useful, currently trying to piece together what I want to do from about 10 other plugins.

The only documentation I have found is here: http://docs.sonarqube.org/display/SONAR/Developing+Plugins


回答1:


To my knowledge, there is no such concept as a global metric/measure in SonarQube. Aggregating metrics across projects is one of the features of the (commercial) Portfolio Management plugin.

If I were to develop such kind of plugin by myself, I would probably do the aggregation based on the result of a Measure Filter.




回答2:


You can create global widgets by annotating them with the org.sonar.api.web.WidgetScope annotation, giving WidgetScope.GLOBAL as its argument:

import org.sonar.api.web.WidgetScope;

@WidgetScope(GLOBAL)
public class ExampleWidget extends AbstractRubyTemplate implements RubyRailsWidget {
  ...

Source: http://sonarqube.15.x6.nabble.com/sonar-dev-Global-dashboards-and-plugin-widgets-in-Sonar-3-1-td4999250.html

I do not know which ruby templating functions are available for global widgets.



来源:https://stackoverflow.com/questions/20703300/sonar-plugin-development-create-a-global-metric

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!