Skip to content

Commit dad6d4b

Browse files
committed
cleanup
1 parent 351339e commit dad6d4b

File tree

4 files changed

+44
-15
lines changed

4 files changed

+44
-15
lines changed

docs/Home.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Have a look at the [Jenkins Job DSL Gradle example](https://github.com/sheehan/j
3333
* Enhanced support for the [Multijob Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin)
3434
* Enhanced support for the [NodeJS Plugin](https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin)
3535
* Enhanced support for the [Maven Project Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Maven+Project+Plugin)
36+
* Enhanced support for the [Description Setter Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Description+Setter+Plugin)
3637
* The `tagFilterRegex` argument of `listTagsParam` can be null or empty
3738
* The enum argument of `localRepository` for the Maven job and context has changed, see [[Migration]]
3839
* Support for the older versions of the [Multijob Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin) is deprecated, see [[Migration]]

docs/Job-reference.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ freeStyleJob(String name) { // since 1.30
130130
ant(String targets, String buildFile, String antInstallation,
131131
Closure antClosure = null)
132132
batchFile(String command)
133-
buildDescription(String regexp, String text) // since 1.31
133+
buildDescription(String regexp, String description = null) // since 1.31
134134
conditionalSteps(Closure conditionalClosure)
135135
copyArtifacts(String jobName, String includeGlob, Closure copyArtifactClosure)
136136
copyArtifacts(String jobName, String includeGlob, String targetPath,
@@ -2377,13 +2377,26 @@ batchFile(String commandStr)
23772377
Supports running a Windows batch file as a build step.
23782378

23792379
### Build Description
2380+
23802381
```groovy
2381-
buildDescription(String regexpStr, String descriptionStr)
2382+
job {
2383+
steps {
2384+
buildDescription(String regexp, String description = null)
2385+
}
2386+
}
23822387
```
23832388

2384-
Set build description based upon a RegEx test of the log file, as a build step.
2389+
Set build description based upon a regular expression test of the log file.
23852390
Requires the [Description Setter Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Description+Setter+Plugin)
23862391

2392+
```groovy
2393+
job('example') {
2394+
steps {
2395+
buildDescription(/.*\[INFO\] Uploading project information for [^\s]* ([^\s]*)/)
2396+
}
2397+
}
2398+
```
2399+
23872400
### Gradle
23882401

23892402
```groovy

job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/StepContext.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class StepContext implements Context {
3434
}
3535
}
3636

37-
void buildDescription(String regexpStr, String descriptionStr) {
38-
NodeBuilder nodeBuilder = new NodeBuilder()
39-
stepNodes << nodeBuilder.'hudson.plugins.descriptionsetter.DescriptionSetterBuilder' {
40-
'regexp' regexpStr
41-
'description' descriptionStr
37+
@RequiresPlugin(id = 'description-setter', minimumVersion = '1.9')
38+
void buildDescription(String regexp, String description = null) {
39+
stepNodes << new NodeBuilder().'hudson.plugins.descriptionsetter.DescriptionSetterBuilder' {
40+
delegate.regexp(regexp ?: '')
41+
delegate.description(description ?: '')
4242
}
4343
}
4444

job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/step/StepContextSpec.groovy

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,32 @@ class StepContextSpec extends Specification {
3737
shellStep.command[0].value() == 'echo "Hello from Windows"'
3838
}
3939

40-
def 'call buildDescription method'() {
40+
def 'call buildDescription method with all options'() {
4141
when:
4242
context.buildDescription('[version] (.*)', 'foo \\1')
4343

4444
then:
45-
context.stepNodes != null
46-
context.stepNodes.size() == 1
47-
def descStep = context.stepNodes[0]
48-
descStep.name() == 'hudson.plugins.descriptionsetter.DescriptionSetterBuilder'
49-
descStep.description[0].value() == 'foo \\1'
50-
descStep.regexp[0].value() == '[version] (.*)'
45+
with(context.stepNodes[0]) {
46+
name() == 'hudson.plugins.descriptionsetter.DescriptionSetterBuilder'
47+
children().size() == 2
48+
regexp[0].value() == '[version] (.*)'
49+
description[0].value() == 'foo \\1'
50+
}
51+
_ * jobManagement.requireMinimumPluginVersion('description-setter', '1.9')
52+
}
53+
54+
def 'call buildDescription method with minimum options'() {
55+
when:
56+
context.buildDescription('[version] (.*)')
57+
58+
then:
59+
with(context.stepNodes[0]) {
60+
name() == 'hudson.plugins.descriptionsetter.DescriptionSetterBuilder'
61+
children().size() == 2
62+
regexp[0].value() == '[version] (.*)'
63+
description[0].value() == ''
64+
}
65+
_ * jobManagement.requireMinimumPluginVersion('description-setter', '1.9')
5166
}
5267

5368
def 'call gradle methods'() {

0 commit comments

Comments
 (0)