Appendix B. Velocity templates

Velocity templates are used to customize the content of build notifications. Detailed information about velocity templates can be found at Apache web site. Two variables are defined to help inserting information related to QuickBuild in the build notifications. The first variable is build, which refers to the current build object. From this variable, information such as build version, build status, configuration, build log, revision log can be accessed. JavaDoc of the build class is the definitive guide on what methods or properties can be accessed using this variable. There are a lot of methods defined in this class, you should pay attention to those which start with OGNL: prefix (In QuickBuild, all properties or methods for OGNL expressions can also be used to construct velocity templates). The second variable is system, which refers to the current QuickBuild system. From this variable, information such as calendar, system url can be accessed. From the JavaDoc, you can get the full guide on what methods can be called using this variable.

Other files can be included in the template, as long as they are put under <QuickBuild installation directory>/templates. For example, the default body template for Email notifier contains just one line: #parse ("html_notification.vm"). This line includes and parses content of the file html_notification.vm in templates sub directory of QuickBuild installation directory.

To facilitate writing of your own notification templates, some typical variable references are listed below:

Get the current build version

$build.version

Determine if the current build is successful

$build.successful

Determine if the current build has failed

$build.failed

Get the current build url

$build.url

Get build log url of the current build

$build.buildLogUrl

Get revision log url of the current build

$build.revisionLogUrl

Get build log path of the current build

$build.buildLogPath

Get revision log path of the current build

$build.revisionLogPath

Get name of the current configuration

$build.configuration

Get url of the current configuration

$build.configuration.url

Get log url of the current configuration

$build.configuration.logUrl

Get log path of the current configuration

$build.configuration.logPath

Get 50 lines around the error line of a build log

$system.readFileAsHtml("$build.buildLogPath", ".*ERROR.*", 25)

Get content of a revision log

$system.readFileAsHtml("$build.revisionLogPath")