Skip to content

Commit

Permalink
[JENKINS-33887] Added support for the Phing Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Mar 29, 2016
1 parent c028e8c commit 98c622b
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/Home.md
Expand Up @@ -21,6 +21,8 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins

## Release Notes
* 1.45 (unreleased)
* Added support for the [Phing Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Phing+Plugin)
([JENKINS-33887](https://issues.jenkins-ci.org/browse/JENKINS-33887))
* Added support for the [CMake Plugin](https://wiki.jenkins-ci.org/display/JENKINS/CMake+Plugin)
([JENKINS-33829](https://issues.jenkins-ci.org/browse/JENKINS-33829))
* Added support for the [JIRA Plugin](https://wiki.jenkins-ci.org/display/JENKINS/JIRA+Plugin)
Expand Down
@@ -0,0 +1,12 @@
job('example') {
steps {
phing {
properties('KEY', 'VALUE')
targets('test')
options('--debug')
buildFile('dir1/build.xml')
phingInstallation('Phing 1.8')
useModuleRoot(false)
}
}
}
@@ -0,0 +1,55 @@
package javaposse.jobdsl.dsl.helpers.step

import javaposse.jobdsl.dsl.Context

class PhingContext implements Context {
String phingName = '(Default)'
boolean useModuleRoot = true
String buildFile
final List<String> targets = []
final Map<String, String> properties = [:]
final List<String> options = []

/**
* Specifies the name of the Phing installation to be used for this build step. Defaults to {@code '(Default)'}.
*/
void phingInstallation(String phingInstallation) {
this.phingName = phingInstallation
}

/**
* If set to true, use ModuleRoot as working directory.
* Defaults to {@code true}.
*/
void useModuleRoot(boolean useModuleRoot = true) {
this.useModuleRoot = useModuleRoot
}

/**
* Specifies the custom buildfile directory.
*/
void buildFile(String buildFile) {
this.buildFile = buildFile
}

/**
* Specifies a list of Phing targets to be invoked. Can be called multiple times to add more targets.
*/
void targets(String targets) {
this.targets << targets
}

/**
* Specifies custom properties to be added to the Phing call. Can be called multiple times to add more properties.
*/
void properties(String name, Object value) {
this.properties[name] = value?.toString()
}

/**
* Specifies options to be added to the Phing call. Can be called multiple times to add more options.
*/
void options(String options) {
this.options << options
}
}
Expand Up @@ -1170,6 +1170,36 @@ class StepContext extends AbstractExtensibleContext {
stepNodes << cmakeNode
}

/**
* Invokes a Phing build script.
*
* @since 1.45
*/
@RequiresPlugin(id = 'phing', minimumVersion = '0.13.3')
void phing(@DslContext(PhingContext) Closure closure) {
PhingContext context = new PhingContext()
ContextHelper.executeInContext(closure, context)

Node phingNode = new NodeBuilder().'hudson.plugins.phing.PhingBuilder' {
name(context.phingName ?: '')
useModuleRoot(context.useModuleRoot)
if (context.buildFile) {
buildFile(context.buildFile)
}
if (context.targets) {
targets(context.targets.join('\n'))
}
if (context.properties) {
properties(context.properties.collect { k, v -> "$k=$v" }.join('\n'))
}
if (context.options) {
options(context.options.join('\n'))
}
}

stepNodes << phingNode
}

/**
* @since 1.35
*/
Expand Down
Expand Up @@ -3702,4 +3702,49 @@ class StepContextSpec extends Specification {
}
1 * jobManagement.requireMinimumPluginVersion('cmakebuilder', '2.4.1')
}

def 'call phing methods with no options'() {
when:
context.phing {
}

then:
context.stepNodes.size() == 1
with(context.stepNodes[0]) {
name() == 'hudson.plugins.phing.PhingBuilder'
children().size() == 2
useModuleRoot[0].value() == true
name[0].value() == '(Default)'
}
1 * jobManagement.requireMinimumPluginVersion('phing', '0.13.3')
}

def 'call phing with all options'() {
when:
context.phing {
phingInstallation('Phing 2.8.0')
useModuleRoot(false)
buildFile('src/bf')
targets('bar')
targets('foo')
properties('A', 'B')
properties('C', true)
options('options1')
options('options2')
}

then:
context.stepNodes.size() == 1
with(context.stepNodes[0]) {
name() == 'hudson.plugins.phing.PhingBuilder'
children().size() == 6
name[0].value() == 'Phing 2.8.0'
useModuleRoot[0].value() == false
buildFile[0].value() == 'src/bf'
targets[0].value() == 'bar\nfoo'
properties[0].value() == 'A=B\nC=true'
options[0].value() == 'options1\noptions2'
}
1 * jobManagement.requireMinimumPluginVersion('phing', '0.13.3')
}
}

0 comments on commit 98c622b

Please sign in to comment.