Skip to content

Commit 31ae709

Browse files
committed
cleanup
1 parent abd2dcb commit 31ae709

File tree

5 files changed

+46
-38
lines changed

5 files changed

+46
-38
lines changed

docs/Home.md

Lines changed: 1 addition & 0 deletions
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 [Debian Package Builder Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Debian+Package+Builder+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)

docs/Job-reference.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ freeStyleJob(String name) { // since 1.30
139139
boolean flattenFiles, boolean optionalAllowed,
140140
Closure copyArtifactClosure)
141141
criticalBlock(Closure stepClosure) // since 1.24
142-
debianPackage(String path, Closure debianClosure)
142+
debianPackage(String path, Closure debianClosure = null) // since 1.31
143143
downstreamParameterized(Closure downstreamClosure)
144144
dsl(Closure dslClosure)
145145
dsl(String scriptText, String removedJobAction = null,
@@ -3045,21 +3045,35 @@ When a job is checked the following conditions must be validated before the job
30453045

30463046
(Since 1.19)
30473047

3048-
# [Debian Package Builder Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Debian+Package+Builder+Plugin)
3048+
# Debian Package Builder
30493049

30503050
```groovy
3051-
debianPackage(String path, Closure debianClosure) {
3052-
signPackage(true) // Sign package with GPG (key configured in Jenkins settings)
3053-
generateChangelog(false) // Build changelog from Git
3054-
buildEvenWhenThereAreNoChanges(false) // Build package if no changes has been made in SCM
3051+
job {
3052+
step {
3053+
debianPackage(String path) {
3054+
signPackage(boolean sign = true) // defaults to true
3055+
generateChangelog(String nextVersion = null, boolean alwaysBuild = false)
3056+
}
3057+
}
30553058
}
30563059
```
30573060

3058-
Supports <a href="https://wiki.jenkins-ci.org/display/JENKINS/Debian+Package+Builder+Plugin">the Debian PackageBuilder Plugin</a>.
3061+
Requires the [Debian Package Builder Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Debian+Package+Builder+Plugin).
30593062

3060-
Path refers to a path in the workspace where the 'debian' catalog is stored.
3063+
The `path` parameter refers to a path in the workspace where the 'debian' catalog is stored. The plugin will
3064+
automatically install packages required to build Debian packages.
30613065

3062-
The plugin will automatically install packages required to build Debian packages.
3066+
```groovy
3067+
job {
3068+
step {
3069+
debianPackage('module') {
3070+
generateChangelog()
3071+
}
3072+
}
3073+
}
3074+
```
3075+
3076+
(since 1.31)
30633077

30643078
# [Parameterized Trigger as Build Step](https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin)
30653079

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,18 @@ package javaposse.jobdsl.dsl.helpers.step
33
import javaposse.jobdsl.dsl.Context
44

55
class DebianContext implements Context {
6-
String nextVersion
76
boolean generateChangelog
8-
boolean signPackage
9-
boolean buildEvenWhenThereAreNoChanges
7+
String nextVersion
8+
boolean alwaysBuild
9+
boolean signPackage = true
1010

11-
void nextVersion(String nextVersion) {
11+
void generateChangelog(String nextVersion = null, boolean alwaysBuild = false) {
12+
this.generateChangelog = true
1213
this.nextVersion = nextVersion
14+
this.alwaysBuild = alwaysBuild
1315
}
1416

15-
void generateChangelog(boolean generateChangelog) {
16-
this.generateChangelog = generateChangelog
17-
}
18-
19-
void signPackage(boolean signPackage) {
17+
void signPackage(boolean signPackage = true) {
2018
this.signPackage = signPackage
2119
}
22-
23-
void buildEvenWhenThereAreNoChanges(boolean buildEvenWhenThereAreNoChanges) {
24-
this.buildEvenWhenThereAreNoChanges = buildEvenWhenThereAreNoChanges
25-
}
26-
2720
}

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
@@ -1118,7 +1118,7 @@ class StepContext implements Context {
11181118
}
11191119

11201120
/**
1121-
* <ru.yandex.jenkins.plugins.debuilder.DebianPackageBuilder plugin="debian-package-builder@1.6.6">
1121+
* <ru.yandex.jenkins.plugins.debuilder.DebianPackageBuilder>
11221122
* <pathToDebian>package</pathToDebian>
11231123
* <nextVersion></nextVersion>
11241124
* <generateChangelog>false</generateChangelog>
@@ -1127,19 +1127,19 @@ class StepContext implements Context {
11271127
* </ru.yandex.jenkins.plugins.debuilder.DebianPackageBuilder>
11281128
*/
11291129
void debianPackage(String path, @DslContext(DebianContext) Closure closure = null) {
1130+
jobManagement.requireMinimumPluginVersion('debian-package-builder', '1.6.6')
1131+
11301132
Preconditions.checkArgument(!isNullOrEmpty(path), 'path must be specified')
11311133

11321134
DebianContext context = new DebianContext()
11331135
ContextHelper.executeInContext(closure, context)
11341136

11351137
stepNodes << new NodeBuilder().'ru.yandex.jenkins.plugins.debuilder.DebianPackageBuilder' {
11361138
pathToDebian(path)
1137-
if (context.nextVersion != null) {
1138-
nextVersion(context.nextVersion)
1139-
}
1139+
nextVersion(context.nextVersion ?: '')
11401140
generateChangelog(context.generateChangelog)
11411141
signPackage(context.signPackage)
1142-
buildEvenWhenThereAreNoChanges(context.buildEvenWhenThereAreNoChanges)
1142+
buildEvenWhenThereAreNoChanges(context.alwaysBuild)
11431143
}
11441144
}
11451145
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,35 +2457,35 @@ still-another-dsl.groovy'''
24572457
context.debianPackage('package')
24582458

24592459
then:
2460-
context.stepNodes.size() == 1
24612460
with(context.stepNodes[0]) {
24622461
name() == 'ru.yandex.jenkins.plugins.debuilder.DebianPackageBuilder'
2462+
children().size() == 5
24632463
pathToDebian[0].value() == 'package'
2464-
signPackage[0].value() == false
2464+
nextVersion[0].value() == ''
24652465
generateChangelog[0].value() == false
2466+
signPackage[0].value() == true
24662467
buildEvenWhenThereAreNoChanges[0].value() == false
24672468
}
2468-
2469+
_ * jobManagement.requireMinimumPluginVersion('debian-package-builder', '1.6.6')
24692470
}
24702471

24712472
def 'call debian package with all options'() {
24722473
when:
24732474
context.debianPackage('package') {
2474-
signPackage(true)
2475-
generateChangelog(true)
2476-
buildEvenWhenThereAreNoChanges(true)
2475+
signPackage(false)
2476+
generateChangelog('1.0', true)
24772477
}
24782478

24792479
then:
2480-
context.stepNodes.size() == 1
24812480
with(context.stepNodes[0]) {
24822481
name() == 'ru.yandex.jenkins.plugins.debuilder.DebianPackageBuilder'
2482+
children().size() == 5
24832483
pathToDebian[0].value() == 'package'
2484-
signPackage[0].value() == true
2484+
nextVersion[0].value() == '1.0'
24852485
generateChangelog[0].value() == true
2486+
signPackage[0].value() == false
24862487
buildEvenWhenThereAreNoChanges[0].value() == true
24872488
}
2488-
2489+
_ * jobManagement.requireMinimumPluginVersion('debian-package-builder', '1.6.6')
24892490
}
2490-
24912491
}

0 commit comments

Comments
 (0)