Skip to content

Commit 3387104

Browse files
committed
Merge branch 'NodeJsCommandInterpreter'
Conflicts: docs/Home.md
2 parents e14b267 + e8b735a commit 3387104

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

docs/Home.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Have a look at the [Jenkins Job DSL Gradle example](https://github.com/sheehan/j
2828
* Added support for [Xvfb Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Xvfb+Plugin)
2929
* Enhanced support for the [Credentials Binding Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Binding+Plugin)
3030
* Enhanced support for the [Multijob Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin)
31+
* Enhanced support for the [NodeJS Plugin](https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin)
3132
* The enum argument of `localRepository` for the Maven job and context has changed, see [[Migration]]
3233
* Added partial support for [Plot Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Plot+Plugin)
3334
* Support for the older versions of the [Multijob Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin) is deprecated, see [[Migration]]

docs/Job-reference.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ freeStyleJob(String name) { // since 1.30
156156
groovyCommand(String command, String groovyName, Closure groovyClosure = null)
157157
groovyScriptFile(String fileName, Closure groovyClosure = null)
158158
groovyScriptFile(String fileName, String groovyName, Closure groovyClosure = null)
159+
nodejsCommand(String command, String nodeVersion) // since 1.31
159160
httpRequest(String url, Closure closure = null) // since 1.28
160161
maven(Closure mavenClosure) // since 1.20
161162
maven(String target = null, String pom = null, Closure configure = null)
@@ -2209,6 +2210,28 @@ job('example') {
22092210

22102211
(since 1.27)
22112212

2213+
### NodeJS Command
2214+
2215+
```groovy
2216+
job {
2217+
steps {
2218+
nodejsCommand(String command, String nodeVersion)
2219+
}
2220+
}
2221+
```
2222+
2223+
Executes a NodeJS script. Requires the [NodeJS Plugin](https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin).
2224+
2225+
```groovy
2226+
job {
2227+
steps {
2228+
nodejsCommand('console.log("Hello World!")', 'Node 0.12.0')
2229+
}
2230+
}
2231+
```
2232+
2233+
(since 1.31)
2234+
22122235
### Golang
22132236

22142237
```groovy

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,4 +1046,17 @@ class StepContext implements Context {
10461046
}
10471047
}
10481048
}
1049+
1050+
/**
1051+
* <jenkins.plugins.nodejs.NodeJsCommandInterpreter>
1052+
* <command>console.log("Hello World!")</command>
1053+
* <nodeJSInstallationName>Node 0.12.0</nodeJSInstallationName>
1054+
* </jenkins.plugins.nodejs.NodeJsCommandInterpreter>
1055+
*/
1056+
void nodejsCommand(String commandScript, String installation) {
1057+
stepNodes << new NodeBuilder().'jenkins.plugins.nodejs.NodeJsCommandInterpreter' {
1058+
command(commandScript)
1059+
nodeJSInstallationName(installation)
1060+
}
1061+
}
10491062
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,4 +2243,17 @@ still-another-dsl.groovy'''
22432243
where:
22442244
mode << ['GET', 'POST', 'PUT', 'DELETE']
22452245
}
2246+
2247+
def 'call nodejsCommand method'() {
2248+
when:
2249+
context.nodejsCommand('var test = require("node");', 'node (0.0.1)')
2250+
2251+
then:
2252+
with(context.stepNodes[0]) {
2253+
name() == 'jenkins.plugins.nodejs.NodeJsCommandInterpreter'
2254+
children().size() == 2
2255+
command[0].value() == 'var test = require("node");'
2256+
nodeJSInstallationName[0].value() == 'node (0.0.1)'
2257+
}
2258+
}
22462259
}

0 commit comments

Comments
 (0)