Skip to content

Commit 81b8982

Browse files
author
Rob Langley
committed
Plots - add support for XML filetypes
1 parent 7212cde commit 81b8982

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,13 @@ class PlotContext implements Context {
6969

7070
dataSeriesList << plotSeriesContext
7171
}
72+
73+
void xmlFile(String fileName, Closure plotSeriesClosure = null) {
74+
checkArgument(!Strings.isNullOrEmpty(fileName), 'fileName must not be null or empty')
75+
76+
PlotSeriesContext plotSeriesContext = new PlotXMLContext(fileName)
77+
ContextHelper.executeInContext(plotSeriesClosure, plotSeriesContext)
78+
79+
dataSeriesList << plotSeriesContext
80+
}
7281
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package javaposse.jobdsl.dsl.helpers.publisher
2+
3+
import static com.google.common.base.Preconditions.checkArgument
4+
5+
class PlotXMLContext extends PlotSeriesContext {
6+
private static final List<String> NODETYPES = [
7+
'NODESET', 'NODE', 'STRING', 'BOOLEAN', 'NUMBER'
8+
]
9+
10+
String nodeType = 'NODESET'
11+
String url
12+
String xpath
13+
14+
PlotXMLContext(String fileName) {
15+
super(fileName, 'xml', 'XMLSeries')
16+
}
17+
18+
void nodeType(String nodeType) {
19+
checkArgument(NODETYPES.contains(nodeType), "nodeType must be one of ${NODETYPES.join(', ')}")
20+
this.nodeType = nodeType
21+
}
22+
23+
void url(String url) {
24+
this.url = url
25+
}
26+
27+
void xpath(String xpath) {
28+
this.xpath = xpath
29+
}
30+
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,14 @@ class PublisherContext implements Context {
348348
* <label>test</label>
349349
* <fileType>properties</fileType>
350350
* </hudson.plugins.plot.PropertiesSeries>
351+
* <hudson.plugins.plot.XMLSeries>
352+
* <file>XML</file>
353+
* <label></label>
354+
* <fileType>xml</fileType>
355+
* <xpathString></xpathString>
356+
* <url></url>
357+
* <nodeTypeString>NODESET</nodeTypeString>
358+
* </hudson.plugins.plot.XMLSeries>
351359
* </series>
352360
* <group>test</group>
353361
* <numBuilds/>
@@ -380,6 +388,12 @@ class PublisherContext implements Context {
380388
file(data.fileName)
381389
label(data.label ?: '')
382390
fileType(data.fileType)
391+
392+
if (data.seriesType == 'XMLSeries') {
393+
nodeTypeString(data.nodeType ?: '')
394+
url(data.url ?: '')
395+
xpathString(data.xpath ?: '')
396+
}
383397
}
384398
}
385399
}

0 commit comments

Comments
 (0)