[Buildbot-devel] Dynamically updating text displayed in build step status

Grig Gheorghiu grig at gheorghiu.net
Wed Mar 29 19:43:55 UTC 2006


Hi,

I've been trying to find ways to dynamically update the text that is
displayed in the build step status in the HTML Waterfall page.

For static customization of the text, I just subclassed from
ShellCommand and I set 'descriptionDone' to my custom text.

However, I also wanted to be able to display a piece of information
(such as a version number) that was computed by the slave running that
build step. I looked through the mailing list, but I couldn't find
something that covered my exact situation, so I came up with the
following:

Assume there's a build step where the slave installs some package and
identifies its version number. I want to be able to display that
version number in the status for that build step.

I defined the following subclass of ShellCommand:

class ClientInstall(ShellCommand):
    name = "client install"
    description = ["running %s" % name]
    descriptionDone = [name]

    def __init__(self, **kwargs):
        ShellCommand.__init__(self, **kwargs)
        self.version = None

    def createSummary(self, log):
        log_text = log.getText()
        s = re.search("--version=(.*)", log_text)
        if s:
           self.version = s.group(1)

    def getText(self, cmd, results):
        text = self.describe(True)
        for elem in text:
            if re.search("version", elem):
                return text
        if results == WARNINGS:
            text += ["warnings"]
        if results == FAILURE:
            text += ["failed"]
        if self.version:
            text += ["version=" + self.version]
        return text


I'm retrieving the version number via a regular expression match from
the slave's log file. Then I'm appending this version to the list
returned by getText.

Note that I had to add this condition inside getText:

        for elem in text:
            if re.search("version", elem):
                return text

otherwise the my custom addition would appear several times in the
status text (which means that getText got called repeatedly).

I'm using my custom ClientInstall class as one of the steps defined in
master.cfg.

Question: am I on the right track here, or am I needlessly complicating
my life?

Thanks,

Grig Gheorghiu




More information about the devel mailing list