Skip to content

Commit b975da4

Browse files
Merge pull request #76 from jenkinsci/docu
adjust documentation for new plugin api
2 parents c2d4766 + c5c4bee commit b975da4

File tree

13 files changed

+76
-27
lines changed

13 files changed

+76
-27
lines changed

README.md

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ An example json file looks like this:
3838
```
3939
{
4040
"id": "my-json-report"
41-
"name": "My JSON report"
4241
"items": [
4342
{
4443
"id": "stocks",
@@ -106,12 +105,11 @@ To check your json you can use the [json schema](src/main/resources/report.json)
106105

107106
> ⚠️ **Color Mapping**:
108107
>
109-
> You can provide a color mapping. Then, please make sure, that the attribute `colors needs exactly the same
108+
> You can provide a color mapping. Then, please make sure, that the attribute `colors` needs exactly the same
110109
> attributes as the result of the items and assigns a color to each attribute, which is used for the graphical representation.
111110
> Otherwise a default color `#E9E9E9` is used for the missing property!
112-
>
113-
> If no `colors` object is provided,
114-
> a color palette will be calculated. You can use own HEX values or the following predefined colors are supported:
111+
>
112+
> You can use own HEX values or the following predefined colors are supported:
115113
> * YELLOW
116114
> * LIME
117115
> * GREEN
@@ -124,6 +122,8 @@ To check your json you can use the [json schema](src/main/resources/report.json)
124122
> * BROWN
125123
> * GRAY
126124
> * WHITE
125+
>
126+
> If no `colors` object is provided, a color palette will be calculated.
127127
128128
If your items only have one result, the visualization is different from the default one,
129129
because the representation then makes no sense. Instead of the attributes of the result object,
@@ -132,7 +132,6 @@ the keys of the individual items are used as the basis for distribution. For exa
132132
```
133133
{
134134
"id": "my-second-json-report"
135-
"name": "My second JSON report"
136135
"items": [
137136
{
138137
"id": "Aktie",
@@ -221,8 +220,6 @@ Then your dashboard looks like this:
221220
* XML
222221
* CSV
223222

224-
For examples of report files, please have look into [etc](/etc) folder.
225-
226223
### Visualization
227224

228225
At job level, a trend chart is generated showing the development
@@ -242,21 +239,37 @@ available in the json model. On the lowest level only the pie chart and the hist
242239

243240
### Pipeline Step
244241

242+
For examples of report files and pipelines, please have look into [etc](/etc) folder.
243+
245244
```
246-
publishReport pattern: "**/result-*.json", displayType: "absolute"
245+
publishReport name: "JSON Report", displayType: "dual", provider: json(pattern: "etc/report-1-part-*.json")
246+
publishReport name: "XML Report", displayType: "dual", provider: xml(pattern: "etc/*.xml")
247+
publishReport name: "YAML Report", displayType: "dual", provider: yaml(pattern: "etc/*.yaml")
248+
publishReport name: "CSV Report", displayType: "dual", provider: csv(id: "csv-one", pattern: "etc/*.csv")
247249
```
248250

249251
### Parameter:
250252

251-
##### pattern:
253+
#### name:
254+
Choose a name for the report. The name is shown in the UI.
252255

253-
This is an ant include pattern for the files should be parsed and scanned (see Patterns in the Apache Ant Manual).
254-
Multiple includes can be specified by separating each pattern with a comma.
255-
At the moment only yaml/yml or json files are supported.
256+
#### displayType (optional, default = `absolute`):
257+
This can be used to change the display of the displayed metrics within the distribution table.
258+
'absolute' shows the absolute values from the underlying files. 'relative', shows percentage values
259+
and 'dual' shows the absolute value and additionally the relative frequency within the category.
260+
261+
#### provider:
262+
Choose a provider that should find and parse the files based on the given pattern.
263+
If all files found have the same ID and can be structurally merged, they are merged into one report.
264+
The id of the first report file found will be used as master id. All following reports of the pattern must match it, otherwise
265+
they are ignored.
256266

257-
##### displayType (optional, default = `absolute`):
258-
This can be used to determine the representation of the values within the table.
259-
Choose between `absolute`, `relative` or `dual`.
267+
##### id (only required for CSV provider):
268+
Specify the id of the report to tag the result and to find reports of past builds. Just required for CSV provider.
269+
270+
##### pattern:
271+
This is an ant include pattern for the files should be parsed and scanned (see Patterns in the Apache Ant Manual).
272+
Multiple includes can be specified by separating each pattern with a comma.
260273

261274
## Issues
262275

etc/Jenkinsfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ pipeline {
55
stage('Publish Data') {
66
steps {
77
checkout scm
8-
publishReport name: "JSON Report", displayType: "dual", provider: json(pattern: "etc/report-1-part-*.json")
8+
publishReport name: "First JSON Report", displayType: "dual", provider: json(pattern: "etc/report-1-part-*.json")
9+
publishReport name: "Second JSON Report", displayType: "dual", provider: json(pattern: "etc/report-2.json")
910
publishReport name: "XML Report", displayType: "dual", provider: xml(pattern: "etc/*.xml")
1011
publishReport name: "YAML Report", displayType: "dual", provider: yaml(pattern: "etc/*.yaml")
1112
publishReport name: "CSV Report", displayType: "dual", provider: csv(id: "csv-one", pattern: "etc/*.csv")

etc/report-2.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"id": "report-two",
3+
"items": [
4+
{
5+
"id": "Aktie",
6+
"name": "Aktie",
7+
"result": {
8+
"incorrect": 3441,
9+
"manually": 348,
10+
"accurate": 5199
11+
}
12+
}
13+
],
14+
"colors": {
15+
"incorrect": "#EF9A9A",
16+
"manually": "#FFF59D",
17+
"accurate": "#A5D6A7"
18+
}
19+
}

etc/ui-3.8.0-oc.png

166 KB
Loading

etc/ui-3.8.0.png

170 KB
Loading

src/main/java/io/jenkins/plugins/reporter/model/Report.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.jenkins.plugins.reporter.model;
22

33
import com.google.errorprone.annotations.FormatMethod;
4+
import org.apache.commons.io.FilenameUtils;
45
import org.apache.commons.lang3.StringUtils;
56
import org.apache.commons.lang3.exception.ExceptionUtils;
67

@@ -105,18 +106,20 @@ public void add(Report report) {
105106

106107
if (StringUtils.isEmpty(id)) {
107108
setId(report.getId());
108-
logInfo("Add first report. Set ID='%s'", report.getId());
109+
logInfo("First added report. Set ID='%s'", report.getId());
109110
}
110111

111112
if (getId().equals(report.getId())) {
113+
logInfo("Add report with ID='%s'.", report.getId());
114+
112115
this.subReports.add(report);
113116
this.infoMessages.addAll(report.getInfoMessages());
114117
this.errorMessages.addAll(report.getErrorMessages());
115118
addColors(report.getColors());
116119
addItems(report.getItems());
117120
logInfo("Successfully added report with ID='%s'", report.getId());
118121
} else {
119-
logError("Skip adding report because ID='%s' is different from parent ID='%s'.",
122+
logInfo("Skip adding report with ID='%s' because it does not match parent ID='%s'.",
120123
report.getId(), getId());
121124
}
122125
}

src/main/java/io/jenkins/plugins/reporter/util/FilesScanner.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ private void aggregateReport(final Path file, final Report aggregatedReport) {
7171
try {
7272
Report report = parser.parse(file.toFile()).toReport();
7373
aggregatedReport.logInfo("Successfully parsed file %s", file);
74-
aggregatedReport.logInfo("Add report with ID='%s' and filename NAME='%s'.",
75-
report.getId(), FilenameUtils.getName(file.toString()));
7674
aggregatedReport.add(report);
75+
7776
} catch (IOException exception) {
7877
aggregatedReport.logException(exception, "Parsing of file '%s' failed due to an exception:", file);
7978
}

src/main/resources/io/jenkins/plugins/reporter/model/Provider/config.jelly

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?jelly escape-by-default='true'?>
22
<j:jelly xmlns:j="jelly:core" xmlns:c="/controls" xmlns:f="/lib/form">
33

4-
<f:entry name="id" title="${%Id}" field="id">
4+
<f:entry name="id" title="${%Id}" field="id" description="${%id.description}">
55

66
<f:textbox/>
77

88
</f:entry>
99

1010
<f:entry title="${%Pattern}" field="pattern"
11-
description="${%description.patternRequired('http://ant.apache.org/manual/Types/fileset.html')}">
11+
description="${%pattern.description('http://ant.apache.org/manual/Types/fileset.html')}">
1212

1313
<c:safe-textbox/>
1414

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
description.patternRequired=<a href="{0}">Fileset ''includes''</a> syntax \
1+
pattern.description=<a href="{0}">Fileset ''includes''</a> syntax \
22
specifying the files to scan for reports, \
3-
such as ''**/target/report.json''.
3+
such as ''**/target/report.json''.
4+
id.description=ID of this provider, it must be unique to tag the report and retrieve reports of past builds.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div>
2+
Normally the ID of the report is read via the underlying file. With a CSV provider this is not possible,
3+
because in a csv file you have no possibility to specify it in a structured way.
4+
Therefore the CSV provider needs an ID to tag the read report and to find reports of past builds to create the history.
5+
</div>

0 commit comments

Comments
 (0)