One more info about python-wrapper plugin. You can use it also for easy
Jython scripting in your Java plugin even if you are not interested in the
pure Python plugin development. This will be described on the wiki page,
but there is some example how you can use it:
1)
Mark the python-wrapper plugin as a dependency in your plugin's pom.xml:
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>python-wrapper</artifactId>
<version>1.0</version></dependency>
2)
Mark all .py files as resource in your pom.xml:
<resource>
<directory>src/main</directory>
<includes>
<include>**/*.py</include>
</includes>
</resource>
3)
Add your python files to the src/main/python directory.
4)
Init and use PythonExecutor object in your Java class:
...
import jenkins.python.*
...
class MyClass {
...
private void someMethod {
PythonExecutor pexec = new PythonExecutor(this);
bool result = pexec.execPythonBool("some_function", "some example",
DataConvertor.fromInt(12));
}
}
5)
Previous Java method will invoke some_function("some example", 12) in the
src/main/python/my_class.py file. The name of the python file is important,
because this file is automatically found by PythonExecutor according Java class
name of the object from which it is initialized.
Example of the my_class.py file:
def some_function(text, length):
return (len(text) == length)
So that's easy Jython scripting with the python-wrapper plugin! See other
PythonExecutor and DataConvertor methods for all possibilities.
You can also place some python library to the python directory and import it in
your python file.
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.