Skip to content

Commit

Permalink
[JENKINS-33881] Added support for Jython Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Mar 29, 2016
1 parent c028e8c commit 3f0be7a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
@@ -0,0 +1,6 @@
job('example') {
steps {
jython('print "Hello" + "Goodbye"')
jython(readFileFromWorkspace('build.py'))
}
}
Expand Up @@ -1170,6 +1170,19 @@ class StepContext extends AbstractExtensibleContext {
stepNodes << cmakeNode
}

/**
* Runs a jython script.
*
* Use {@link javaposse.jobdsl.dsl.DslFactory#readFileFromWorkspace(java.lang.String) readFileFromWorkspace} to read
* the script from a file.
* @since 1.45
*/
void jython(String command) {
stepNodes << new NodeBuilder().'org.jvnet.hudson.plugins.Jython' {
delegate.command(command)
}
}

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

def 'call jython method'() {
when:
context.jython('print "Hello" + "Goodbye"')

then:
context.stepNodes != null
context.stepNodes.size() == 1
with(context.stepNodes[0]) {
name() == 'org.jvnet.hudson.plugins.Jython'
command[0].value() == 'print "Hello" + "Goodbye"'
}
}
}

0 comments on commit 3f0be7a

Please sign in to comment.