Although OGNL expression is widely used in QuickBuild, generally, you need not know anything about it due to QuickBuild's deliberate designed user interface. For most properties that need OGNL expression, you can choose from drop down menu besides that property simply. However, knowledge of OGNL expression will give you ability to set up very complicated configurations. http://www.ognl.org is the official site for OGNL where you can learn everything about it. This chapter assumes that you have some knowledge of it, and will concentrate on properties and methods that can be used in QuickBuild.
Generally, there are two types of application 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 in ${...}, and QuickBuild expects they evaluate to a value of string type. Strings outside of ${...} will simply keep the same during the evaluation. Every string-typed property in QuickBuild accepts OGNL expressions embedded within ${...} as long as there is not explicitly statement of nonsupport. Please be noted 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 OGNL expression, then that windows path should also use double back slashes. For example, in order to assign windows path of ant executable to 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.
Maybe you know, every OGNL expression should have a root object in order to perform the evaluation. In QuickBuild, the root object is always current configuration object. From this configuration object, you can access its exposed methods or properties, such as name, status, variables, repositories, builders, steps, current build, current object, etc. Once you get a stuff out of the configuration object, you can recursively get other properties or methods exposed by that particular property. The definitive guide of these exposed methods or properties is the JavaDoc. There are a lot of methods 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.startDate, configuration)
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