Skip to content

Commit 351339e

Browse files
kshtskdaspilker
authored andcommitted
Added Description Setter Plugin support
1 parent 28b4139 commit 351339e

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

docs/Job-reference.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +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
133134
conditionalSteps(Closure conditionalClosure)
134135
copyArtifacts(String jobName, String includeGlob, Closure copyArtifactClosure)
135136
copyArtifacts(String jobName, String includeGlob, String targetPath,
@@ -2375,6 +2376,14 @@ batchFile(String commandStr)
23752376

23762377
Supports running a Windows batch file as a build step.
23772378

2379+
### Build Description
2380+
```groovy
2381+
buildDescription(String regexpStr, String descriptionStr)
2382+
```
2383+
2384+
Set build description based upon a RegEx test of the log file, as a build step.
2385+
Requires the [Description Setter Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Description+Setter+Plugin)
2386+
23782387
### Gradle
23792388

23802389
```groovy

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ 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
42+
}
43+
}
44+
3745
void gradle(@DslContext(GradleContext) Closure gradleClosure) {
3846
GradleContext gradleContext = new GradleContext()
3947
ContextHelper.executeInContext(gradleClosure, gradleContext)

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

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

40+
def 'call buildDescription method'() {
41+
when:
42+
context.buildDescription('[version] (.*)', 'foo \\1')
43+
44+
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] (.*)'
51+
}
52+
4053
def 'call gradle methods'() {
4154
when:
4255
context.gradle('build')

0 commit comments

Comments
 (0)