Although OGNL expressions are widely used in QuickBuild, generally, you do not need to know anything about OGNL because QuickBuild's user interface hides most of the OGNL expressions. For most properties that need an OGNL expression, you can choose from drop down menu. However, knowledge of OGNL expressions will give you an ability to set up very complicated and powerfull configurations. You can learn about OGNL at http://www.ognl.org, which is the official site for OGNL. This chapter assumes that you have some knowledge of OGNL, and it will concentrate on the properties and methods that can be used in QuickBuild.
Generally, there are two types of OGNL in QuickBuild. The first one is for boolean type properties, including Build necessary condition, Step necessary condition, Build success condition, Step success condition, etc. These properties expect an OGNL expression that will be evaluated to a boolean value. The second one is for string type properties. Inside this string, any number of OGNL expressions can be embedded as long as they are embedded with ${...} expression. QuickBuild expects that they evaluate to a value of type string. Strings outside of ${...} expression will simply keep the same value during the evaluation. Every string-typed property in QuickBuild accepts OGNL expressions embedded within ${...} expression as long as it is not stated otherwise. Please note that double back slashes should be used for windows path in an OGNL expression, for example, ${"c:\\program files\\apache-ant-1.6.5\\bin\\ant.bat"}. Further more, if you assign Windows path as value of a variable, and refer to that variable in an OGNL expression, then that Windows path should also use double back slashes. For example, in order to assign Windows path of an ant executable to the variable pathToAnt, you may need to define it as:
pathToAnt = "c:\\program files\\apache-ant-1.6.5\\bin\\ant.bat"
The path is quoted because there are spaces inside it.
Every OGNL expression needs a root object in order to perform the evaluation. In QuickBuild, the root object is always the current configuration object. From this configuration object, you can access its exposed methods or properties, such as name, status, variables, repositories, builders, steps, the current build, the current object, etc. Once you get a stuff out of the configuration object, you can recursively get the other properties or methods exposed by that particular property. The definitive guide of these exposed methods or properties is the QuickBuild's JavaDoc. There are lots of methods and/or properties in the JavaDoc, you should only pay attention to methods or properties with OGNL: at the very beginning of the comment. Here are some typical OGNL expressions:
build
build.version
lastBuild
lastSuccessBuild
lastBuild.successful
lastBuild.failed
lastBuild.running
repository["cvs1"].modified
repository["svn1"].modules.get(0).srcPath
repository["svn1"].headRevision
repository["accurev1"].getWorkspaceDir(build)
repository["quickbuild1"].remoteBuild.version
effectingRepositoriesModified
lastSuccessBuild==null or repository["cvs1"].isModifiedSince(lastSuccessBuild)
var["var1"]
var["var1"].intValue
var["var1"].increaseAsInt()
var["var1"].setValue("value1")
var["var1"].(increaseAsInt(), value)
var["var1"].value=="true"
workingDir
system.execute("/path/to/my/command") == 0
system.calendar.hour
system.calendar.dayOfWeek
step["step1"].successful