Skip to content

Commit

Permalink
[FIXED JENKINS-31883] Added support for NAnt plugin
Browse files Browse the repository at this point in the history
Added a release notes for NAnt Plugin and since tag
  • Loading branch information
v1v committed Dec 16, 2015
1 parent 6532c4b commit cdf2e4c
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 1 deletion.
4 changes: 3 additions & 1 deletion 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.42 (unreleased)
* Added support for the [NAnt Plugin](https://wiki.jenkins-ci.org/display/JENKINS/NAnt+Plugin)
([JENKINS-31883](https://issues.jenkins-ci.org/browse/JENKINS-31883))
* Added support for the [Ruby Metrics Plugin](https://wiki.jenkins-ci.org/display/JENKINS/RubyMetrics+plugin)
([JENKINS-31830](https://issues.jenkins-ci.org/browse/JENKINS-31830))
* Added support for the [DOS Trigger Plugin](https://wiki.jenkins-ci.org/display/JENKINS/DOS+Trigger)
Expand Down Expand Up @@ -631,4 +633,4 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins
* extendedEmail(recipients, subject, content, closure) - Configure email-ext plugin
* gerrit(closure) - Configure Gerrit Trigger plugin
* 1.0
* Initial release
* Initial release
@@ -0,0 +1,12 @@
job('example') {
steps {
nant {
target('test')
targets(['publish', 'deploy'])
prop('logging', 'info')
props('test.threads': 10, 'input.status': 'release')
buildFile('dir1/build.xml')
nantInstallation('NAnt 1.8')
}
}
}
@@ -0,0 +1,56 @@
package javaposse.jobdsl.dsl.helpers.step

import javaposse.jobdsl.dsl.Context

class NAntContext implements Context {
List<String> targets = []
List<String> props = []
String buildFile
String nantInstallation

/**
* Specifies an NAnt target to be invoked. Can be called multiple times to add more targets.
*/
void target(String target) {
targets << target
}

/**
* Specifies NAnt targets to be invoked. Can be called multiple times to add more targets.
*/
void targets(Iterable<String> targets) {
targets.each {
target(it)
}
}

/**
* Specifies a property for the NAnt build. Can be called multiple times to add more properties.
*/
void prop(Object key, Object value) {
props << "${key}=${value}"
}

/**
* Specifies properties for the NAnt build. Can be called multiple times to add more properties.
*/
void props(Map<String, String> map) {
map.entrySet().each {
prop(it.key, it.value)
}
}

/**
* Specifies the build file to be invoked.
*/
void buildFile(String buildFile) {
this.buildFile = buildFile
}

/**
* Specifies the name of the NAnt installation to be used for this build step.
*/
void nantInstallation(String nantInstallationName) {
nantInstallation = nantInstallationName
}
}
Expand Up @@ -1085,6 +1085,26 @@ class StepContext extends AbstractExtensibleContext {
}
}

/**
* Invokes a NAnt build script.
*
* @since 1.42
*/
@RequiresPlugin(id = 'nant', minimumVersion = '1.4.3')
void nant(@DslContext(NAntContext) Closure closure = null) {
NAntContext context = new NAntContext()
ContextHelper.executeInContext(closure, context)

stepNodes << new NodeBuilder().'hudson.plugins.nant.NantBuilder' {
delegate.targets(context.targets.join(' ') ?: '')
nantName(context.nantInstallation ?: '(Default)')
nantBuildFile(context.buildFile ?: '')
if (context.props) {
properties(context.props.join('\n'))
}
}
}

/**
* @since 1.35
*/
Expand Down
Expand Up @@ -3595,4 +3595,48 @@ class StepContextSpec extends Specification {
}
1 * jobManagement.requireMinimumPluginVersion('ruby', '1.2')
}

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

then:
context.stepNodes.size() == 1
with(context.stepNodes[0]) {
name() == 'hudson.plugins.nant.NantBuilder'
targets[0].value().empty
nantBuildFile[0].value().empty
nantName[0].value() == '(Default)'
!children().any { it.name() == 'properties' }
}
1 * jobManagement.requireMinimumPluginVersion('nant', '1.4.3')

}

def 'call nant with all options'() {
when:
context.nant {
target('test')
target('integTest')
targets(['publish', 'deploy'])
prop('test.size', 4)
prop('logging', 'info')
props('test.threads': 10, 'input.status': 'release')
buildFile('dir2/nant.build')
buildFile('dir1/nant.build')
nantInstallation('NAnt 1.6')
nantInstallation('NAnt 1.7')
}

then:
context.stepNodes.size() == 1
with (context.stepNodes[0]) {
nantBuildFile[0].value() == 'dir1/nant.build'
nantName[0].value() == 'NAnt 1.7'
targets[0].value() == 'test integTest publish deploy'
properties[0].value() == 'test.size=4\nlogging=info\ntest.threads=10\ninput.status=release'
}
1 * jobManagement.requireMinimumPluginVersion('nant', '1.4.3')
}
}

0 comments on commit cdf2e4c

Please sign in to comment.