BusyB: The sendMail element


Introduction

News

Reference

Installation

Quick Start

Download

 

As the name suggests, the sendMail element sends an email message. Typically you would use sendMail in two places:

  • Inside a <step> element, instead of the <cmd> -- this way you can send mail in the ordinary course of a build, or...

  • from inside an onError element, to send mail when something goes wrong.

The example below shows a fairly typical sendMail element:

    <sendMail>
      <to>fred@acme.com</to>
      <from>george@acme.com</from>
      <subject>The build failed!!!</subject>
      <body>You should look into this.</body>
    </sendMail>

The sendMail element uses SMTP to send out the email and defaults to "localhost" and the standard SMTP port, but you can override these:

    <sendMail>
      <host>mail.acme.com</host>
      <port>1233</port>
      <to>fred@acme.com</to>
      <from>george@acme.com</from>
      <subject>The build failed!!!</subject>
      <body>You should look into this.</body>
    </sendMail>

You can also set the default host, port, etc. that the sendmail element will use when you start busyb. Simply use the -e argument:

$ busyb.py -eMailHost=myhost.com -eMailPort=250 -eMailFrom=fred@hogwarts.com -eMailSubject=Hello

If you are using sendMail to handle an build problem from within  <onError>, busyb will set two handy symbols for you:  

  • !(ex_message) is set to a short message describing the problem

  • !(ex_details) is set to the last 2K bytes of the log file of the step that had a problem

So a more useful version of the sendMail element above might be:

    <sendMail>
      <host>mail.acme.com</host>
      <port>1233</port>
      <to>fred@acme.com</to>
      <from>george@acme.com</from>
      <subject>The build failed: !(ex_details)</subject>
     <body>!(ex_details)</body>
    </sendMail>