声纳插件开发 - 创建全局指标 [英] Sonar Plugin Development - Create a global metric

查看:216
本文介绍了声纳插件开发 - 创建全局指标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个自定义声纳插件,该插件由全局仪表板上的小部件组成。

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.

这是可能的,如果是这样的话我怎么能这样做?我只能找到运行项目特定指标的示例项目。他们在ruby模板中输出它们,如下所示: format_measure('random')。我猜这种格式测量只适用于项目环境。

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.

在整个过程中,文档非常亮。因此,如果有人知道任何有用的文档或指南,目前正试图将我想要做的事情从其他10个插件拼凑起来。

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.

唯一的文档我发现在这里: http://docs.sonarqube.org/display/SONAR/Developing +插件

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

推荐答案

您可以通过使用org.sonar.api.web.WidgetScope对它们进行注释来创建全局小部件注释,将WidgetScope.GLOBAL作为其参数:

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 {
  ...

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

我不知道哪些ruby模板函数可用于全局小部件。

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

这篇关于声纳插件开发 - 创建全局指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆