View Source

QuickBuild support add your custom statistics data and will generate the statistics chart and build overview automatically. For example, we use a test framework named rubyunit and want QuickBuild to collect the following indicators: total test count, failed test count, passed test count and total duration, then we will:

h3. Add a custom statistics category
First, we will define the statistics data structure in QuickBuild. To define the data structure:
1. Log in to the QuickBuild server as Administrator
2. Click the 'Administration' tab in main navigation
3. Click the 'Plugin Management' tab
4. Click the 'Configure' link of 'Custom Statistics Report' plugin
5. Click 'Add New' button to add a new custom statistics category
6. Define the information of rubyunit like below

||Field Name||Description||Required||
|*Category Name*|The name of the category. It will be used as tab name in statistics page and also will be used as an overview section in build overview page. *The category name should be unique in the whole QuickBuild.*|YES|
|*Ordinal*|The order of the category. The QuickBuild will use this value to determine the position of this category when displayed in statistics page and build overview page.|YES|
|*Description*|The description of the category.|NO|
|*Indicators*|Indicators are what you want QuickBuild to collect from your original reports.|YES|

7. Click 'Save' button.

Indicator id should be started with an alphabetic character (a-z or A-Z). For example:
Indicator123 is a good id, while 123Indicator is not.

h4. Publish JSON report

The custom statistics data can also be in JSON format. QuickBuild uses [JSON-Path|] to parse the JSON file.

Below operators are supported:

| Operator | Description |
| `$` | The root element to query. This starts all path expressions. |
| `@` | The current node being processed by a filter predicate. |
| `*` | Wildcard. Available anywhere a name or numeric are required. |
| `..` | Deep scan. Available anywhere a name is required. |
| `.<name>` | Dot-notated child |
| `\['<name>' (, '<name>')]` | Bracket-notated child or children |
| `\[<number> (, <number>)]` | Array index or indexes |
| `\[start:end]` | Array slice operator |
| `\[?(<expression>)]` | Filter expression. Expression must evaluate to a boolean value. |

Below functions are supported

Functions can be invoked at the tail end of a path - the input to a function is the output of the path expression.
The function output is dictated by the function itself.

| Function | Description | Output type |
| min() | Provides the min value of an array of numbers | Double |
| max() | Provides the max value of an array of numbers | Double |
| avg() | Provides the average value of an array of numbers | Double |
| stddev() | Provides the standard deviation value of an array of numbers | Double |
| length() | Provides the length of an array | Integer |
| sum() | Provides the sum value of an array of numbers | Double |
| keys() | Provides the property keys (An alternative for terminal tilde `~`) | `Set<E>` |
| concat(X) | Provides a concatinated version of the path output with a new item | like input |
| append(X) | add an item to the json path output array | like input |
| first() | Provides the first item of an array | Depends on the array |
| last() | Provides the last item of an array | Depends on the array |
| index(X) | Provides the item of an array of index: X, if the X is negative, take from backwards | Depends on the array |

Please see [JSON-Path|] page for more detailed information.

h3. Collect the statistics data
After defining the custom statistics category, you can now add a publish 'Custom Statistics Report' step:

In this step, you can select a category which you defined before and then publish the XML reports where you want QuickBuild to collect the statistics data from. Just like all other publish report step, here you can specify the file patterns, step failure condition and failure message.

Now, you can run your configuration. After running finished, QuickBuild will show the indicators value in Build Dashboard like below:

and display the statistics chart in Statistics tab like below: