[Buildbot-devel] Sending CVS change mail to developers

Javier Somoza jsomoza at pandasoftware.es
Fri Feb 17 12:48:50 UTC 2006


    Im using this (adding it to the master.cfg) to send a mail to the
developers about a commit on the cvs.
    Surely this will not be the best way (i've just done it and havent
got time to enhance it) but if someone finds it useful...


import sys, os, os.path, string, smtplib, MimeWriter, mimetypes, base64,
tempfile, StringIO

sender = "cvs-change at buildbot"
changeRecipients = []
changeRecipients.append("developer1 at domain,")
changeRecipients.append("developer2 at domain,")
changeRecipients.append("developer3 at domain")

def addHtml(mime, infile):
    part = mime.nextpart()
    part.addheader("Content-Transfer-Encoding", "7bit")
    outfile = part.startbody("text/html", [("charset","us-ascii")])
    while 1:
        s = infile.read(BLK_SIZE)
        if not s: break
        outfile.write(s)

def createCVSMail(message):
    msgfile = open("/tmp/cvs-commit.eml","w")
    mime = MimeWriter.MimeWriter(msgfile)
    mime.addheader("To", string.join(changeRecipients))
    mime.addheader("From", sender)
    mime.addheader("Subject", "CVS change")
    mime.addheader("MIME-Version", "1.0")
    mime.startmultipartbody("mixed")
    f = StringIO.StringIO(message)
    addHtml(mime, f)
    f.close
    mime.lastpart()
    msgfile.flush()
    msgfile.close()

def manageChange (changes):
        server = smtplib.SMTP('192.168.1.4')
        createCVSMail(changes.asHTML())
        msg = open('/tmp/cvs-commit.eml', 'r').read()
        server.sendmail(sender, changeRecipients, msg)
        os.remove("/tmp/cvs-commit.eml")
        server.quit()

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://buildbot.net/pipermail/devel/attachments/20060217/742d8214/attachment.html>


More information about the devel mailing list