Chapter 5. Velocity templates

## Chapter 5. Velocity templates

Velocity templates are used to customize content of build notifications. Detailed information about velocity template can be accessed from Apache's web site. Two variables are defined to help inserting information related to QuickBuild. The first variable is build, which refers to 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 will be the definitive guide on what methods or properties can be accessed from this variable. There are a lot of methods defined in this class, you should pay attention to those started 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 current QuickBuild system. From this variable, information such as calendar, system url can be accessed. Again from the JavaDoc, you can get the full guide on what methods can be called on 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 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 current build version

  $build.version

Determine if current build is successful

  $build.successful

Determine if current build is failed

  $build.failed

Get current build url

  $build.url

Get build log url of current build

  $build.buildLogUrl

Get revision log url of current build

  $build.revisionLogUrl

Get build log path of current build

  $build.buildLogPath

Get revision log path of current build

  $build.revisionLogPath

Get name of current configuration

  $build.configuration

Get url of current configuration

  $build.configuration.url

Get log url of current configuration

  $build.configuration.logUrl

Get log path of current configuration

  $build.configuration.logPath

Get 50 lines arround the error line of build log

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

Get content of revision log

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

Chapter 4. OGNL expressions |  | Chapter 6. Security