Skip to main content
Version: QB13

Add Custom Statistics Data

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:

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 NameDescriptionRequired
Category NameThe 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
OrdinalThe 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
DescriptionThe description of the category.NO
IndicatorsIndicators are what you want QuickBuild to collect from your original reports.YES
  1. Click 'Save' button.
warning

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.

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:

OperatorDescription
`$`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.

FunctionDescriptionOutput type
min()Provides the min value of an array of numbersDouble
max()Provides the max value of an array of numbersDouble
avg()Provides the average value of an array of numbersDouble
stddev()Provides the standard deviation value of an array of numbersDouble
length()Provides the length of an arrayInteger
sum()Provides the sum value of an array of numbersDouble
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 itemlike input
append(X)add an item to the json path output arraylike input
first()Provides the first item of an arrayDepends on the array
last()Provides the last item of an arrayDepends on the array
index(X)Provides the item of an array of index: X, if the X is negative, take from backwardsDepends on the array

Please see JSON-Path page for more detailed information.

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: