Skip to content

Commit ce12fcf

Browse files
committed
Merge branch 'xvfb'
Conflicts: docs/Home.md
2 parents c2903ba + 0cc011e commit ce12fcf

File tree

5 files changed

+174
-0
lines changed

5 files changed

+174
-0
lines changed

docs/Home.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Have a look at the [Jenkins Job DSL Gradle example](https://github.com/sheehan/j
2222
* Added support for [Sonar Plugin](http://docs.sonarqube.org/display/SONAR/Jenkins+Plugin)
2323
* Added `ignorePostCommitHooks` option for SCM trigger
2424
* Added support for [PostBuildScript Plugin](https://wiki.jenkins-ci.org/display/JENKINS/PostBuildScript+Plugin)
25+
* Added support for [Xvfb Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Xvfb+Plugin)
2526
* The enum argument of `localRepository` for the Maven job and context has changed, see [[Migration]]
2627
* Added partial support for [Plot Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Plot+Plugin)
2728
* 1.30 (March 08 2015)

docs/Job-reference.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ freeStyleJob(String name) { // since 1.30
118118
timeout(Closure timeoutClosure = null)
119119
timestamps()
120120
toolenv(String... tools)
121+
xvfb(String installation, Closure xvfbClosure = null) // since 1.31
121122
xvnc(boolean takeScreenshot) // deprecated
122123
xvnc(Closure xvncClosure = null) // since 1.26
123124
}
@@ -1694,6 +1695,38 @@ job('example') {
16941695

16951696
(Since 1.19)
16961697

1698+
### Xvfb
1699+
1700+
```groovy
1701+
job {
1702+
wrappers {
1703+
xvfb(String xvfbInstallation) {
1704+
screen(String screen) // defaults to 1024x768x24
1705+
debug(boolean debug = true) // defaults to false
1706+
timeout(int timeout) // defaults to 0
1707+
displayNameOffset(int displayNameOffset) // defaults to 1
1708+
shutdownWithBuild(boolean shutdownWithBuild = true) // defaults to false
1709+
autoDisplayName(boolean autoDisplayName = true) // defaults to false
1710+
assignedLabels(String labels)
1711+
parallelBuild(boolean parallelBuild = true) // defaults to false
1712+
}
1713+
}
1714+
}
1715+
```
1716+
1717+
Controls the Xvfb virtual frame buffer X11 server. Requires the
1718+
[Xvfb Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Xvfb+Plugin).
1719+
1720+
```groovy
1721+
job {
1722+
wrappers {
1723+
xvfb('default') {
1724+
screen('1920x1080x24')
1725+
}
1726+
}
1727+
}
1728+
```
1729+
16971730
### Xvnc
16981731

16991732
```groovy

job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/wrapper/WrapperContext.groovy

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package javaposse.jobdsl.dsl.helpers.wrapper
22

33
import com.google.common.base.Preconditions
4+
import com.google.common.base.Strings
45
import hudson.util.VersionNumber
56
import javaposse.jobdsl.dsl.Context
67
import javaposse.jobdsl.dsl.ContextHelper
@@ -308,6 +309,40 @@ class WrapperContext implements Context {
308309
}
309310
}
310311

312+
/**
313+
* <org.jenkinsci.plugins.xvfb.XvfbBuildWrapper>
314+
* <installationName>xvfb</installationName>
315+
* <screen>1024x768x24</screen>
316+
* <debug>false</debug>
317+
* <timeout>0</timeout>
318+
* <displayNameOffset>1</displayNameOffset>
319+
* <shutdownWithBuild>false</shutdownWithBuild>
320+
* <autoDisplayName>false</autoDisplayName>
321+
* <assignedLabels>xvfb</assignedLabels>
322+
* <parallelBuild>false</parallelBuild>
323+
* </org.jenkinsci.plugins.xvfb.XvfbBuildWrapper>
324+
*/
325+
void xvfb(String installation, @DslContext(XvfbContext) Closure closure = null) {
326+
Preconditions.checkArgument(!Strings.isNullOrEmpty(installation), 'installation must not be null or empty')
327+
328+
XvfbContext context = new XvfbContext()
329+
ContextHelper.executeInContext(closure, context)
330+
331+
wrapperNodes << new NodeBuilder().'org.jenkinsci.plugins.xvfb.XvfbBuildWrapper' {
332+
installationName(installation)
333+
screen(context.screen)
334+
debug(context.debug)
335+
timeout(context.timeout)
336+
displayNameOffset(context.displayNameOffset)
337+
shutdownWithBuild(context.shutdownWithBuild)
338+
autoDisplayName(context.autoDisplayName)
339+
if (context.assignedLabels) {
340+
assignedLabels(context.assignedLabels)
341+
}
342+
parallelBuild(context.parallelBuild)
343+
}
344+
}
345+
311346
/**
312347
* <pre>
313348
* {@code
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package javaposse.jobdsl.dsl.helpers.wrapper
2+
3+
import javaposse.jobdsl.dsl.Context
4+
5+
class XvfbContext implements Context {
6+
String screen = '1024x768x24'
7+
boolean debug = false
8+
int timeout = 0
9+
int displayNameOffset = 1
10+
boolean shutdownWithBuild = false
11+
boolean autoDisplayName = false
12+
String assignedLabels
13+
boolean parallelBuild = false
14+
15+
void screen(String screen) {
16+
this.screen = screen
17+
}
18+
19+
void debug(boolean debug = true) {
20+
this.debug = debug
21+
}
22+
23+
void timeout(int timeout) {
24+
this.timeout = timeout
25+
}
26+
27+
void displayNameOffset(int displayNameOffset) {
28+
this.displayNameOffset = displayNameOffset
29+
}
30+
31+
void shutdownWithBuild(boolean shutdownWithBuild = true) {
32+
this.shutdownWithBuild = shutdownWithBuild
33+
}
34+
35+
void autoDisplayName(boolean autoDisplayName = true) {
36+
this.autoDisplayName = autoDisplayName
37+
}
38+
39+
void assignedLabels(String assignedLabels) {
40+
this.assignedLabels = assignedLabels
41+
}
42+
43+
void parallelBuild(boolean parallelBuild = true) {
44+
this.parallelBuild = parallelBuild
45+
}
46+
}

job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/wrapper/WrapperContextSpec.groovy

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,65 @@ class WrapperContextSpec extends Specification {
413413
wrapper.takeScreenshot[0].value() == false
414414
}
415415

416+
def 'xvfb with minimal options'() {
417+
when:
418+
context.xvfb('default')
419+
420+
then:
421+
with(context.wrapperNodes[0]) {
422+
name() == 'org.jenkinsci.plugins.xvfb.XvfbBuildWrapper'
423+
children().size() == 8
424+
installationName[0].value() == 'default'
425+
screen[0].value() == '1024x768x24'
426+
debug[0].value() == false
427+
timeout[0].value() == 0
428+
displayNameOffset[0].value() == 1
429+
shutdownWithBuild[0].value() == false
430+
autoDisplayName[0].value() == false
431+
parallelBuild[0].value() == false
432+
}
433+
}
434+
435+
def 'xvfb with all options'() {
436+
when:
437+
context.xvfb('default') {
438+
screen('1920x1080x32')
439+
debug()
440+
timeout(500)
441+
displayNameOffset(24)
442+
shutdownWithBuild()
443+
autoDisplayName()
444+
assignedLabels('test')
445+
parallelBuild()
446+
}
447+
448+
then:
449+
with(context.wrapperNodes[0]) {
450+
name() == 'org.jenkinsci.plugins.xvfb.XvfbBuildWrapper'
451+
children().size() == 9
452+
installationName[0].value() == 'default'
453+
screen[0].value() == '1920x1080x32'
454+
debug[0].value() == true
455+
timeout[0].value() == 500
456+
displayNameOffset[0].value() == 24
457+
shutdownWithBuild[0].value() == true
458+
autoDisplayName[0].value() == true
459+
assignedLabels[0].value() == 'test'
460+
parallelBuild[0].value() == true
461+
}
462+
}
463+
464+
def 'xvfb without installation'() {
465+
when:
466+
context.xvfb(installation)
467+
468+
then:
469+
thrown(IllegalArgumentException)
470+
471+
where:
472+
installation << [null, '']
473+
}
474+
416475
def 'toolenv' () {
417476
when:
418477
context.toolenv('Ant 1.8.2', 'Maven 3')

0 commit comments

Comments
 (0)