Luntbuild Builder and Schedule can use OGNL expressions. Builder evaluates OGNL expressions of its Build Properties values. Schedule evaluates OGNL expressions of its Next build version. While Builder evaluates OGNL expressions in context of com.luntsys.luntbuild.builders.Builder class, Schedule evaluates OGNL expressions in context of com.luntsys.luntbuild.db.Schedule class. Please see javadoc for detail of classes involved in OGNL expression evaluation.
Following are some examples of available Builder OGNL expressions:
Build version
Build artifacts directory, subdirectory of the build.publishDir.
Build publish directory.
JUnit tests Html reports directory
Build schedule name.
Build schedule description.
Build schedule work directory.
Was VCS modified?
Is dependent schedule newer?
Build project name.
Build project description.
Here are some examples to show the format of the OGNL expressions:
vcsModified - this expression will evaluate to true if the repository content of the current build changes
getProject("testcvs").isVcsModifiedSince("11/11/2005") - this expression will evaluate to true if the "testcvs" project changed since "11/11/2005". For current project the expression would be getProject().isVcsModifiedSince("11/11/2005").
getProject("testcvs").isVcsModified() - this expression will evaluate to true if the "testcvs" project changed since the last build. For current project the expression would be getProject().isVcsModified().
ant("/path/to/command.xml", "targetA") == 0 - this expression will evaluate to true if execution of targetA of ant script file /path/to/command.xml returns success.
![]() | Note |
|---|---|
Special characters such as '\', '"', should be escaped with '\', just like in Java strings. The Ant file path will be assumed relative to current project work directory, if it is not an absolute path. If the target is "" or null, the default target will be assumed. | |
execute("/path/to/command.sh") == 0 - this expression will evaluate to true if the return code of the execution of the specified command is 0.
![]() | Note |
|---|---|
Special characters such as '\', '"', should be escaped with '\', just like in Java strings. | |
The above expressions can be prefixed with '!' to inverse the value, for example !modified will be true when there are no modifications in the repository of the current project.
The above expressions can be joined with "and", and "or". For example, the expression: modified or execute("/path/to/command.sh")==0 will be true, if repository content of the current project changes, or execution of the specified command returns 0.
The above expressions can be prefixed with '!' to negate the value, for example "!modified" will evaluate to true when there are no modifications in the repository of current view. The above expressions can also be joined with "and", "or". For example, the expression modified or execute("/path/to/command.sh")==0 will evaluate to true if the repository content of the current view changes, or execution of the specified command returns 0.
Sometimes in might be handy to have your own class available for OGNL evaluation. Luntbuild supports a simple extension mechanism, so that when a JAR containing luntbuild_extension.properties is placed into Luntbuild's classpath, a class that has been defined in the property file can be accessed trough the system object like this:
| ${system.getExtension("MyExtension").getHelloWorld()} |
Contents of the property file look like this:
| luntbuild.extension.name=MyExtension |
| luntbuild.extension.class=org.example.MyExtension |
The mechanism is built completely into com.luntsys.luntbuild.utility.OgnlHelper class so, that the helper classes are instantiated once and instances stored in a static Hashtable. Methods of the extension classes should be made thread safe.
Please go to http://www.ognl.org to learn more about general grammar of an OGNL expression.