The publisher can be used to collect and update statistics for each build in a file. Some of the statistics which would be collected are build durations and test count.
At the minimal, the publisher can be configured with just an empty <statistics /> element in the publishers section. This would pick up some default statistics for capturing during the build process.
<publishers>
<statistics />
</publishers>
NOTE: Statistics publisher must come after any File Merge tasks in the publishers section, in case you want to collect statistics from merged files.
If you want to specify your own, or override the default statistics, it is possible to do so by supplying the name and xpath for the statistics and the corresponding location in the build log to pick the data from.
<publishers>
<statistics>
<statisticList>
<statistic name='metric_name' xpath='xpath expression'/>
<firstMatch name='metric_name' xpath='xpath expression' />
<statisticList/>
</statistics>
</publishers>
FirstMatch is a special type of Statistics where you are only interested in the first occurrence in the build log, like the Project Name.
The task will generate a statistics.csv and report.xml file in the artifact directory.
Task Configuration
| Node |
Description |
Type |
Required |
Default |
| statisticList |
The list of statistics to generate. |
List of Statistic elements. |
false |
empty list |
It is also possible to optionally configure the statistics publisher to generate charts for any metric against different builds, and to even remove them altogether. These features has been added in release 1.3
<publishers>
<statistics>
<statisticList>
<statistic name='metric_name' xpath='xpath expression' generateGraph='true' include='true'/>
<firstMatch name='metric_name' xpath='xpath expression' include='false'/>
<statisticList/>
</statistics>
</publishers>
For the statistics configured with "generateGraph='true'", a graph is generated with different builds on x-axis and the configured metric on y-axis in the artifacts directory named as <statistic name>.png. This chart would still be a very basic representation. For now atleast, exporting the report to Excel for charting/analyis might be a better option.
Metrics Configuration
statistic | firstMatch
| Attribute |
Description |
Required |
Default |
| name |
Metric Name |
true |
|
| xpath |
xPath for evaluating the statistic |
true |
|
| generateGraph |
true will generate a graph against different builds |
false |
false |
| include |
whether to publish statistic for this metric |
false |
true |