Skip to content

Commit 3081fc3

Browse files
committed
cleanup
1 parent 9f3cf1c commit 3081fc3

File tree

6 files changed

+51
-40
lines changed

6 files changed

+51
-40
lines changed

docs/Home.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Have a look at the [Jenkins Job DSL Gradle example](https://github.com/sheehan/j
2020
* Added support for [Build Node Column Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Build+Node+Column+Plugin)
2121
* Added support for [Pre-SCM Build Step Plugin](https://wiki.jenkins-ci.org/display/JENKINS/pre-scm-buildstep)
2222
* Added support for [Sonar Plugin](http://docs.sonarqube.org/display/SONAR/Jenkins+Plugin)
23+
* Added support for [Plot Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Plot+Plugin)
2324
* Added `recurse` option for list views
2425
* Added `ignorePostCommitHooks` option for SCM trigger
2526
* Added `commentFilePath` option for [GitHub Pull Request Builder Plugin](https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin)
@@ -28,7 +29,6 @@ Have a look at the [Jenkins Job DSL Gradle example](https://github.com/sheehan/j
2829
* Added support for [Xvfb Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Xvfb+Plugin)
2930
* Enhanced support for the [Credentials Binding Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Binding+Plugin)
3031
* The enum argument of `localRepository` for the Maven job and context has changed, see [[Migration]]
31-
* Added partial support for [Plot Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Plot+Plugin)
3232
* 1.30 (March 08 2015)
3333
* Added support for [Custom Tools Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Custom+Tools+Plugin)
3434
* Added support for [Flaky Test Handler Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Flaky+Test+Handler+Plugin)

docs/Job-reference.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3877,13 +3877,13 @@ job {
38773877
publishers {
38783878
plotBuildData {
38793879
plot(String group, String dataStore) {
3880-
title(String title) // optional
3881-
yaxis(String yaxis) // optional
3882-
numBuilds(int numBuilds) // optional
3883-
useDescr(boolean useDescr = true) // optional
3884-
keepRecords(boolean keepRecords = true) // optional
3885-
exclZero(boolean exclZero = true) // optional
3886-
style(String style) // defaults to 'line'
3880+
title(String title)
3881+
numberOfBuilds(int numberOfBuilds)
3882+
yAxis(String yAxis)
3883+
style(String style) // defaults to 'line'
3884+
useDescriptions(boolean useDescriptions = true) // defaults to false
3885+
excludeZero(boolean excludeZero = true) // defaults to false
3886+
keepRecords(boolean keepRecords = true) // defaults to false
38873887
propertiesFile(String fileName) {
38883888
label(String label)
38893889
}
@@ -3932,11 +3932,11 @@ job {
39323932
plotBuildData {
39333933
plot('Exciting plots', 'excitment.csv') {
39343934
title('X vs Y')
3935-
yaxis('Y')
3936-
numBuilds(42)
3937-
useDescr()
3935+
yAxis('Y')
3936+
numberOfBuilds(42)
3937+
useDescriptions()
39383938
keepRecords()
3939-
exclZero()
3939+
excludeZero()
39403940
propertiesFile('my_data.properties') {
39413941
label('Builds')
39423942
}

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class PlotContext implements Context {
1414
final String group
1515
final String dataStore
1616
final List<PlotSeriesContext> dataSeriesList = []
17-
String title = ''
18-
String yaxis = ''
17+
String title
18+
String yAxis
1919
String style = 'line'
20-
int numBuilds
21-
boolean useDescr = false
22-
boolean keepRecords = false
23-
boolean exclZero = false
20+
Integer numberOfBuilds
21+
boolean useDescriptions
22+
boolean keepRecords
23+
boolean excludeZero
2424

2525
PlotContext(String group, String dataStore) {
2626
this.group = group
@@ -31,29 +31,29 @@ class PlotContext implements Context {
3131
this.title = title
3232
}
3333

34-
void yaxis(String yaxis) {
35-
this.yaxis = yaxis
34+
void yAxis(String yAxis) {
35+
this.yAxis = yAxis
3636
}
3737

3838
void style(String style) {
3939
checkArgument(STYLE.contains(style), "style must be one of ${STYLE.join(', ')}")
4040
this.style = style
4141
}
4242

43-
void numBuilds(int numBuilds) {
44-
this.numBuilds = numBuilds
43+
void numberOfBuilds(int numberOfBuilds) {
44+
this.numberOfBuilds = numberOfBuilds
4545
}
4646

47-
void useDescr(boolean useDescr = true) {
48-
this.useDescr = useDescr
47+
void useDescriptions(boolean useDescriptions = true) {
48+
this.useDescriptions = useDescriptions
4949
}
5050

5151
void keepRecords(boolean keepRecords = true) {
5252
this.keepRecords = keepRecords
5353
}
5454

55-
void exclZero(boolean exclZero = true) {
56-
this.exclZero = exclZero
55+
void excludeZero(boolean excludeZero = true) {
56+
this.excludeZero = excludeZero
5757
}
5858

5959
void propertiesFile(String fileName, Closure plotSeriesClosure = null) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import com.google.common.base.Preconditions
44
import com.google.common.base.Strings
55
import javaposse.jobdsl.dsl.ContextHelper
66
import javaposse.jobdsl.dsl.Context
7+
import javaposse.jobdsl.dsl.DslContext
78

89
class PlotsContext implements Context {
910
final List<PlotContext> plots = []
1011

11-
void plot(String group, String dataStore, Closure plotClosure) {
12+
void plot(String group, String dataStore, @DslContext(PlotContext) Closure plotClosure) {
1213
Preconditions.checkArgument(!Strings.isNullOrEmpty(group), 'group must not be null or empty')
1314
Preconditions.checkArgument(!Strings.isNullOrEmpty(dataStore), 'dataStore must not be null or empty')
1415

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,20 +357,23 @@ class PublisherContext implements Context {
357357
* <useDescr>false</useDescr>
358358
* <keepRecords>false</keepRecords>
359359
* <exclZero>false</exclZero>
360+
* <logarithmic>false</logarithmic>
360361
* </hudson.plugins.plot.Plot>
361362
* </plots>
362363
* </hudson.plugins.plot.PlotPublisher>
363364
*/
364-
void plotBuildData(Closure plotsClosure) {
365+
void plotBuildData(@DslContext(PlotsContext) Closure plotsClosure) {
366+
jobManagement.requireMinimumPluginVersion('plot', '1.9')
367+
365368
PlotsContext plotsContext = new PlotsContext()
366369
ContextHelper.executeInContext(plotsClosure, plotsContext)
367370

368371
publisherNodes << NodeBuilder.newInstance().'hudson.plugins.plot.PlotPublisher' {
369372
plots {
370373
plotsContext.plots.each { PlotContext plot ->
371374
'hudson.plugins.plot.Plot' {
372-
title(plot.title)
373-
yaxis(plot.yaxis)
375+
title(plot.title ?: '')
376+
yaxis(plot.yAxis ?: '')
374377
series {
375378
plot.dataSeriesList.each { PlotSeriesContext data ->
376379
'hudson.plugins.plot.PropertiesSeries' {
@@ -381,13 +384,14 @@ class PublisherContext implements Context {
381384
}
382385
}
383386
group(plot.group)
384-
numBuilds(plot.numBuilds ?: '')
387+
numBuilds(plot.numberOfBuilds ?: '')
385388
csvFileName(plot.dataStore)
386389
csvLastModification(0)
387390
style(plot.style)
388-
useDescr(plot.useDescr)
391+
useDescr(plot.useDescriptions)
389392
keepRecords(plot.keepRecords)
390-
exclZero(plot.exclZero)
393+
exclZero(plot.excludeZero)
394+
logarithmic(false)
391395
}
392396
}
393397
}

job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContextSpec.groovy

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3094,7 +3094,7 @@ class PublisherContextSpec extends Specification {
30943094
name() == 'hudson.plugins.plot.PlotPublisher'
30953095
children().size() == 1
30963096
with(plots.'hudson.plugins.plot.Plot'[0]) {
3097-
children().size() == 11
3097+
children().size() == 12
30983098
title[0].value().empty
30993099
yaxis[0].value().empty
31003100
group[0].value() == 'my group'
@@ -3105,6 +3105,7 @@ class PublisherContextSpec extends Specification {
31053105
useDescr[0].value() == false
31063106
keepRecords[0].value() == false
31073107
exclZero[0].value() == false
3108+
logarithmic[0].value() == false
31083109
with(series[0].'hudson.plugins.plot.PropertiesSeries'[0]) {
31093110
children().size() == 3
31103111
file[0].value() == 'data.prop'
@@ -3113,18 +3114,19 @@ class PublisherContextSpec extends Specification {
31133114
}
31143115
}
31153116
}
3117+
_ * jobManagement.requireMinimumPluginVersion('plot', '1.9')
31163118
}
31173119

31183120
def 'call plotPlugin with all args'() {
31193121
when:
31203122
context.plotBuildData {
31213123
plot('my group', 'some.csv') {
31223124
title('plot title')
3123-
yaxis('yaxis title')
3124-
numBuilds(42)
3125-
useDescr()
3125+
yAxis('yaxis title')
3126+
numberOfBuilds(42)
3127+
useDescriptions()
31263128
keepRecords()
3127-
exclZero()
3129+
excludeZero()
31283130
propertiesFile('data.prop')
31293131
}
31303132
}
@@ -3134,7 +3136,7 @@ class PublisherContextSpec extends Specification {
31343136
name() == 'hudson.plugins.plot.PlotPublisher'
31353137
children().size() == 1
31363138
with(plots.'hudson.plugins.plot.Plot'[0]) {
3137-
children().size() == 11
3139+
children().size() == 12
31383140
title[0].value() == 'plot title'
31393141
yaxis[0].value() == 'yaxis title'
31403142
group[0].value() == 'my group'
@@ -3145,6 +3147,7 @@ class PublisherContextSpec extends Specification {
31453147
useDescr[0].value() == true
31463148
keepRecords[0].value() == true
31473149
exclZero[0].value() == true
3150+
logarithmic[0].value() == false
31483151
with(series[0].'hudson.plugins.plot.PropertiesSeries'[0]) {
31493152
children().size() == 3
31503153
file[0].value() == 'data.prop'
@@ -3153,6 +3156,7 @@ class PublisherContextSpec extends Specification {
31533156
}
31543157
}
31553158
}
3159+
_ * jobManagement.requireMinimumPluginVersion('plot', '1.9')
31563160
}
31573161

31583162
def 'call plotPlugin with all chart styles'() {
@@ -3171,7 +3175,7 @@ class PublisherContextSpec extends Specification {
31713175
name() == 'hudson.plugins.plot.PlotPublisher'
31723176
children().size() == 1
31733177
with(plots.'hudson.plugins.plot.Plot'[0]) {
3174-
children().size() == 11
3178+
children().size() == 12
31753179
title[0].value().empty
31763180
yaxis[0].value().empty
31773181
group[0].value() == 'my group'
@@ -3182,6 +3186,7 @@ class PublisherContextSpec extends Specification {
31823186
useDescr[0].value() == false
31833187
keepRecords[0].value() == false
31843188
exclZero[0].value() == false
3189+
logarithmic[0].value() == false
31853190
with(series[0].'hudson.plugins.plot.PropertiesSeries'[0]) {
31863191
children().size() == 3
31873192
file[0].value() == 'data.prop'
@@ -3190,6 +3195,7 @@ class PublisherContextSpec extends Specification {
31903195
}
31913196
}
31923197
}
3198+
_ * jobManagement.requireMinimumPluginVersion('plot', '1.9')
31933199

31943200
where:
31953201
chart << ['area', 'bar', 'bar3d', 'line', 'line3d', 'stackedArea', 'stackedbar', 'stackedbar3d', 'waterfall']

0 commit comments

Comments
 (0)