Skip to content

Commit b2e4131

Browse files
committed
cleanup
1 parent 85f3031 commit b2e4131

File tree

6 files changed

+177
-110
lines changed

6 files changed

+177
-110
lines changed

docs/Job-reference.md

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3801,57 +3801,59 @@ The arguments here are in order:
38013801
* (String) the findbugs-files to parse
38023802
* (boolean) use the findbugs rank for the priority, default to false
38033803
3804-
#### [Plot Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Plot+Plugin)
3804+
#### Plot Build Data
3805+
38053806
```groovy
3806-
publishers {
3807-
plotBuildData {
3808-
plot(String dataStore, String group) {
3809-
style(String style = 'line')
3810-
propertiesFile(String fileName) {
3811-
label(String label)
3812-
}
3807+
job {
3808+
publishers {
3809+
plotBuildData {
3810+
plot(String group, String dataStore) {
3811+
style(String style) // defaults to 'line'
3812+
propertiesFile(String fileName) {
3813+
label(String label)
3814+
}
3815+
}
3816+
}
38133817
}
3814-
}
38153818
}
38163819
```
38173820
3818-
Plot plugin is able to show a number of plots, each containing a single data series.
3819-
3820-
`plot` arguments:
3821-
* `dataStore` Plot plugin relies on a data store to hold the plot data, this is normally stored in a randomly named CSV file within the workspace root. To avoid conflicts this location needs to be set manually and is within the workspace root.
3822-
* `group` Specifies to which group the plot belongs.
3823-
* `style` Optional, Specifies which chart style to display the plot data as, one of: 'area', 'bar', 'bar3d', 'line', 'line3d', 'stackedArea', 'stackedbar', 'stackedbar3d', 'waterfall'.
3821+
Show a number of plots, each containing a single data series. Requires the
3822+
[Plot Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Plot+Plugin).
38243823
3825-
`propertiesFile` arguments:
3826-
* `fileName` Specifies the filename that contains this data series, relative to the workspace root.
3827-
* `label` Optional, specifies the legend label for this data series.
3824+
Plot plugin relies on a data store to hold the plot data, this is normally stored in a randomly named CSV file within
3825+
the workspace root. To avoid conflicts this location needs to be set manually relative to the workspace using the
3826+
`dataStore` parameter.
38283827
3829-
Examples:
3828+
The `style` option can be one of `'area'`, `'bar'`, `'bar3d'`, `'line'` (default), `'line3d'`, `'stackedArea'`,
3829+
`'stackedbar'`, `'stackedbar3d'` or `'waterfall'`.
38303830
38313831
```groovy
3832-
publishers {
3833-
plotBuildData {
3834-
plot('my_data_store.csv', 'Important plot') {
3835-
propertiesFile('my_data.prop')
3832+
job {
3833+
publishers {
3834+
plotBuildData {
3835+
plot('Important Plot', 'my_data_store.csv') {
3836+
propertiesFile('my_data.properties')
3837+
}
3838+
}
38363839
}
3837-
}
38383840
}
3839-
```
38403841
3841-
```groovy
3842-
publishers {
3843-
plotBuildData {
3844-
style('bar')
3845-
plot('bar_chart_data_store.csv', 'Bar charts') {
3846-
propertiesFile('my_data.prop') {
3847-
label('My label')
3848-
}
3842+
job {
3843+
publishers {
3844+
plotBuildData {
3845+
plot('Bar Charts', 'bar_chart_data_store.csv') {
3846+
style('bar')
3847+
propertiesFile('my_data.properties') {
3848+
label('My Label')
3849+
}
3850+
}
3851+
}
38493852
}
3850-
}
38513853
}
38523854
```
38533855
3854-
// since 1.31
3856+
(since 1.31)
38553857
38563858
#### [Pmd](https://wiki.jenkins-ci.org/display/JENKINS/PMD+Plugin)
38573859
```groovy

job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/PlotContext.groovy

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package javaposse.jobdsl.dsl.helpers.publisher
22

3+
import com.google.common.base.Strings
34
import javaposse.jobdsl.dsl.ContextHelper
45
import javaposse.jobdsl.dsl.Context
56

@@ -10,14 +11,14 @@ class PlotContext implements Context {
1011
'area', 'bar', 'bar3d', 'line', 'line3d', 'stackedArea', 'stackedbar', 'stackedbar3d', 'waterfall'
1112
]
1213

14+
final String group
15+
final String dataStore
16+
final List<PlotSeriesContext> dataSeriesList = []
1317
String style = 'line'
14-
String dataStore
15-
String group
16-
List<PlotSeriesContext> dataSeriesList = []
1718

18-
PlotContext(String dataStore, String group) {
19-
this.dataStore = dataStore
19+
PlotContext(String group, String dataStore) {
2020
this.group = group
21+
this.dataStore = dataStore
2122
}
2223

2324
void style(String style) {
@@ -26,7 +27,9 @@ class PlotContext implements Context {
2627
}
2728

2829
void propertiesFile(String fileName, Closure plotSeriesClosure = null) {
29-
PlotSeriesContext plotSeriesContext = new PlotSeriesContext(fileName, 'PropertiesSeries', 'properties')
30+
checkArgument(!Strings.isNullOrEmpty(fileName), 'fileName must not be null or empty')
31+
32+
PlotSeriesContext plotSeriesContext = new PlotSeriesContext(fileName)
3033
ContextHelper.executeInContext(plotSeriesClosure, plotSeriesContext)
3134

3235
dataSeriesList << plotSeriesContext

job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/PlotSeriesContext.groovy

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ package javaposse.jobdsl.dsl.helpers.publisher
33
import javaposse.jobdsl.dsl.Context
44

55
class PlotSeriesContext implements Context {
6-
final String type
7-
final String fileType
8-
String file = ''
9-
String label = ''
6+
final String fileName
7+
String label
108

11-
PlotSeriesContext(String fileName, String type, String fileType) {
12-
this.file = fileName
13-
this.type = type
14-
this.fileType = fileType
9+
PlotSeriesContext(String fileName) {
10+
this.fileName = fileName
1511
}
1612

1713
void label(String label) {

job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/PlotsContext.groovy

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
package javaposse.jobdsl.dsl.helpers.publisher
22

3+
import com.google.common.base.Preconditions
4+
import com.google.common.base.Strings
35
import javaposse.jobdsl.dsl.ContextHelper
46
import javaposse.jobdsl.dsl.Context
57

68
class PlotsContext implements Context {
7-
List<PlotContext> plots = []
9+
final List<PlotContext> plots = []
810

9-
void plot(String dataStore, String group, Closure plotClosure) {
10-
PlotContext plotContext = new PlotContext(dataStore, group)
11+
void plot(String group, String dataStore, Closure plotClosure) {
12+
Preconditions.checkArgument(!Strings.isNullOrEmpty(group), 'group must not be null or empty')
13+
Preconditions.checkArgument(!Strings.isNullOrEmpty(dataStore), 'dataStore must not be null or empty')
14+
15+
PlotContext plotContext = new PlotContext(group, dataStore)
1116
ContextHelper.executeInContext(plotClosure, plotContext)
1217

1318
plots << plotContext

job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContext.groovy

Lines changed: 39 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -337,74 +337,61 @@ class PublisherContext implements Context {
337337
}
338338

339339
/**
340-
* <hudson.plugins.plot.PlotPublisher>
341-
* <plots>
342-
* <hudson.plugins.plot.Plot>
343-
* <title></title>
344-
* <yaxis></yaxis>
345-
* <series>
346-
* <hudson.plugins.plot.PropertiesSeries>
347-
* <file>Properties</file>
348-
* <label></label>
349-
* <fileType>properties</fileType>
350-
* </hudson.plugins.plot.PropertiesSeries>
351-
* <hudson.plugins.plot.CSVSeries>
352-
* <file>CSV</file>
353-
* <label></label>
354-
* <fileType>csv</fileType>
355-
* <inclusionFlag>OFF</inclusionFlag>
356-
* <exclusionValues></exclusionValues>
357-
* <url></url>
358-
* <displayTableFlag>false</displayTableFlag>
359-
* </hudson.plugins.plot.CSVSeries>
360-
* <hudson.plugins.plot.XMLSeries>
361-
* <file>XML</file>
362-
* <label></label>
363-
* <fileType>xml</fileType>
364-
* <xpathString></xpathString>
365-
* <url></url>
366-
* <nodeTypeString>NODESET</nodeTypeString>
367-
* </hudson.plugins.plot.XMLSeries>
368-
* </series>
369-
* <group></group>
370-
* <numBuilds></numBuilds>
371-
* <csvFileName></csvFileName>
372-
* <csvLastModification></csvLastModification>
373-
* <style></style>
374-
* <useDescr></useDescr>
375-
* </hudson.plugins.plot.Plot>
376-
* </plots>
377-
* </hudson.plugins.plot.PlotPublisher>
378-
*/
340+
* <hudson.plugins.plot.PlotPublisher>
341+
* <plots>
342+
* <hudson.plugins.plot.Plot>
343+
* <title/>
344+
* <yaxis/>
345+
* <series>
346+
* <hudson.plugins.plot.PropertiesSeries>
347+
* <file>test.properties</file>
348+
* <label>test</label>
349+
* <fileType>properties</fileType>
350+
* </hudson.plugins.plot.PropertiesSeries>
351+
* </series>
352+
* <group>test</group>
353+
* <numBuilds/>
354+
* <csvFileName>744827576.csv</csvFileName>
355+
* <csvLastModification>0</csvLastModification>
356+
* <style>line</style>
357+
* <useDescr>false</useDescr>
358+
* <keepRecords>false</keepRecords>
359+
* <exclZero>false</exclZero>
360+
* </hudson.plugins.plot.Plot>
361+
* </plots>
362+
* </hudson.plugins.plot.PlotPublisher>
363+
*/
379364
void plotBuildData(Closure plotsClosure) {
380-
381365
PlotsContext plotsContext = new PlotsContext()
382366
ContextHelper.executeInContext(plotsClosure, plotsContext)
383367

384-
NodeBuilder nodeBuilder = NodeBuilder.newInstance()
385-
386-
Node plotsNode = nodeBuilder.'hudson.plugins.plot.PlotPublisher' {
368+
publisherNodes << NodeBuilder.newInstance().'hudson.plugins.plot.PlotPublisher' {
387369
plots {
388370
plotsContext.plots.each { PlotContext plot ->
389371
'hudson.plugins.plot.Plot' {
390-
group plot.group
391-
csvFileName plot.dataStore
392-
style plot.style
372+
title()
373+
yaxis()
393374
series {
394375
plot.dataSeriesList.each { PlotSeriesContext data ->
395-
"hudson.plugins.plot.${data.type}" {
396-
file data.file
397-
label data.label
398-
fileType data.fileType
376+
'hudson.plugins.plot.PropertiesSeries' {
377+
file(data.fileName)
378+
label(data.label ?: '')
379+
fileType('properties')
399380
}
400381
}
401382
}
383+
group(plot.group)
384+
numBuilds()
385+
csvFileName(plot.dataStore)
386+
csvLastModification(0)
387+
style(plot.style)
388+
usrDescr(false)
389+
keepRecords(false)
390+
exclZero(false)
402391
}
403392
}
404393
}
405394
}
406-
407-
publisherNodes << plotsNode
408395
}
409396

410397
/**

0 commit comments

Comments
 (0)