Skip to content
Permalink
Browse files

[JENKINS-32195] Added support for JSLint plugin

  • Loading branch information
v1v committed Dec 23, 2015
1 parent 3a19d85 commit 47589a210d073d1cfa10773b061f50b329d62ebc
@@ -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 [JSLint Plugin](https://wiki.jenkins-ci.org/display/JENKINS/JSLint-plugin)
([JENKINS-32195](https://issues.jenkins-ci.org/browse/JENKINS-32195))
* Enhanced support for the
[PostBuildScript Plugin](https://wiki.jenkins-ci.org/display/JENKINS/PostBuildScript+Plugin)
([JENKINS-31853](https://issues.jenkins-ci.org/browse/JENKINS-31853))
@@ -0,0 +1,10 @@
job('example') {
steps {
jslint {
includePattern('**/*.js')
excludePattern('**/*Tests.js')
logFile('target/jslint.xml')
arguments('-Dadsafe=true, -Dcontinue=true')
}
}
}
@@ -0,0 +1,40 @@
package javaposse.jobdsl.dsl.helpers.step

import javaposse.jobdsl.dsl.Context

class JSLintContext implements Context {
String includePattern
String excludePattern
String logFile
String arguments

/**
* Specifies the files to include in an Ant-style filter. You can define multiple filesets using comma as a
* separator
*/
void includePattern(String includePattern) {
this.includePattern = includePattern
}

/**
* Specifies the files to exclude in an Ant-style filter. You can define multiple filesets using comma as a
* separator
*/
void excludePattern(String excludePattern) {
this.excludePattern = excludePattern
}

/**
* Specifies the file to output to in a Checkstyle XML format.
*/
void logFile(String logFile) {
this.logFile = logFile
}

/**
* Specifies the arguments to pass to JSLint. Be sure, though, to prefix each argument with -D and comma separator.
*/
void arguments(String arguments) {
this.arguments = arguments
}
}
@@ -1105,6 +1105,24 @@ class StepContext extends AbstractExtensibleContext {
}
}

/**
* Invokes a JSLint build script.
*
* @since 1.42
*/
@RequiresPlugin(id = 'jslint', minimumVersion = '0.8.2')
void jslint(@DslContext(JSLintContext) Closure closure = null) {
JSLintContext context = new JSLintContext()
ContextHelper.executeInContext(closure, context)

stepNodes << new NodeBuilder().'com.boxuk.jenkins.jslint.JSLintBuilder' {
includePattern(context.includePattern ?: '')
excludePattern(context.excludePattern ?: '')
logfile(context.logFile ?: '')
arguments(context.arguments ?: '')
}
}

/**
* @since 1.35
*/
@@ -3639,4 +3639,44 @@ class StepContextSpec extends Specification {
}
1 * jobManagement.requireMinimumPluginVersion('nant', '1.4.3')
}

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

then:
context.stepNodes.size() == 1
with(context.stepNodes[0]) {
name() == 'com.boxuk.jenkins.jslint.JSLintBuilder'
children().size() == 4
includePattern[0].value().empty
excludePattern[0].value().empty
logfile[0].value().empty
arguments[0].value().empty
}
1 * jobManagement.requireMinimumPluginVersion('jslint', '0.8.2')
}

def 'call jslint with all options'() {
when:
context.jslint {
includePattern('**/*.js')
excludePattern('**/*Tests.js')
logFile('target/jslint.xml')
arguments('-Dadsafe=true, -Dcontinue=true')
}

then:
context.stepNodes.size() == 1
with(context.stepNodes[0]) {
name() == 'com.boxuk.jenkins.jslint.JSLintBuilder'
children().size() == 4
includePattern[0].value() == '**/*.js'
excludePattern[0].value() == '**/*Tests.js'
logfile[0].value() == 'target/jslint.xml'
arguments[0].value() == '-Dadsafe=true, -Dcontinue=true'
}
1 * jobManagement.requireMinimumPluginVersion('jslint', '0.8.2')
}
}

0 comments on commit 47589a2

Please sign in to comment.
You can’t perform that action at this time.