CHAPTER 20 ■ CONTINUOUS INTEGRATION
change that by making CruiseControl a nag. In order to do this you can use a built-in publisher: email,
which you should add to the publishers element in your project's section of the config.xml file:
<email mailhost="smtp.somemail.com"
mailport="465"
username="[email protected]"
password="somepass"
usessl="true"
returnaddress="[email protected]"
buildresultsurl="http://localhost:8080/cruisecontrol/buildresults/${project.name}"
returnname="CruiseControl">
The email element contains all the information needed to connect to a mail server. I've assumed
that an SSL connection is required, but you could omit the mailport and and usessl elements otherwise.
The always element defines an address to which a message should be sent for all builds whether
successful or not. The failure element defines an address to which failure notifications should be sent.
As a bonus, with reportWhenFixed set to true, the failure recipient will also get an all clear message when
a builds are once again successful.
The failure message is very short, consisting of a subject line, which gives the build status and a URL
for the full report.
■Note If you want more verbose messages you should look at the htmlemail publisher, which shares a common
set of attributes and child elements with the email publisher, but also provides additional options to help you
format an inline message. You can find more information about htmlemail at
http://cruisecontrol.sourceforge.net/main/configxml.html#htmlemail.
Adding Your Own Build Targets
So far I have stuck to the toolset supported by phpUnderControl. That gets us a long way, after all.
However you should know that you can quite easily add your own checks to CruiseControl.
The biggest omission so far has been a test of for creating and installing a package. This is
significant, because CI is about build as well as testing. One approach would be to create a PHPUnit test
case which attempts to build and install a package.
In order to illustrate some of CruiseControl's features, though, I propose to perform the build and
install from within the product build file. I’ve already shown you the build target. It invokes the other
targets in the file through its depends attribute. Here I add a new dependency.
<target name="build"
depends="checkout,php-documentor,php-codesniffer,phpunit,install-package"/>
The install-package target does not exist yet. Time to add it.