[Buildbot-devel] Extending buildbot to transmit xml result to the master
Anthony Viallard
avd at patatrac.info
Thu Oct 8 09:26:04 UTC 2009
Le 07/10/2009 16:20, Andy Howell a écrit :
> Anthony Viallard wrote:
>> Hello everybody,
>>
>> I have some difficulties to extend buildbot. I explain: after
>> successful compile, i want to launch a functional test program. This
>> program generate a xml file. So, after finishing the functionnal
>> test, i want to transmit this xml file to the master to make it
>> possible to see it in the webStatus interface (after a transformation
>> in html with xsltproc).
>>
>> I want this:
>>
>> !-----------------!
>> ! tests !
>> ! !
>> ! [result] !
>> ! !
>> !-----------------!
>> ! compile !
>> ! !
>> ! [stdio] !
>> ! !
>> !-----------------!
>> ....
>>
>> And when clicking the result link, the html result page (generated
>> with xml file transmited) is displayed.
>>
>>
>> If i use shellCommand, when clicking on "stdio" link in waterfall
>> webStatus interface, there already a html header generate, some
>> informations on environnement, etc and finaly the result
>> "backquotted" :(
>>
>> I think i have to extend shellCommand class for generating my own
>> page containing the xltproc result of my xml file. But, i don't known
>> what class i must extend (ShellCommand of ./steps/shell.py,
>> ShellCommand of ./slave/commands.py, ...) ?
>>
>> What is the better solution ?
>>
>> Anthony.
>>
>
> Anthony,
>
> I'm quite new to buildbot. I've been experimenting with some code
> to upload a binary distribution after a build:
>
> class DistFileUpload(FileUpload):
> def __init__(self, slavesrc, masterdest,
> workdir=None, maxsize=None, blocksize=16*1024,
> mode=None,
> **kwargs):
> FileUpload.__init__(self, slavesrc, masterdest,
> workdir, maxsize, blocksize, mode,
> **kwargs)
>
> def finished(self, result):
> # if result == SUCCESS:
> buildnumber = self.getProperty("buildnumber")
> buildername = self.getProperty("buildername")
> url = "http://<hostname>/hello-%s-%s.tar" % (buildnumber,
> buildername)
> self.addURL("Binary",url)
> return FileUpload.finished(self,result)
>
> f1 = factory.BuildFactory()
> f1.addStep(CVS(cvsroot=cvsroot, cvsmodule=cvsmodule, login=None,
> mode="copy"))
> f1.addStep(Compile(
> command=["make"]))
> # Pass the buildnumber and builder name to the make file so that it can
> # use them as part of the file anme
> f1.addStep(Compile(
> command=["make", "dist",
> WithProperties("buildno=%s", "buildnumber"),
> WithProperties("builder=%s", "buildername")],
> description = ["building dist"],
> descriptionDone = ["distribution"]))
>
> # Upload the file to the master and add url link to it.
> f1.addStep(DistFileUpload(
> mode = 0644,
> slavesrc=WithProperties("hello-%s-%s.tar", "buildnumber",
> "buildername"),
> masterdest=WithProperties("~/builds/hello-%s-%s.tar",
> "buildnumber", "buildername")))
>
> The class DistFileUpload takes care of uploading the file and then
> adding the link to the waterfall display.
>
> There may be better, cleaner ways to do this, but this is working
> except for the test for SUCCESS in DistFileUpload.finished.
>
>
> Regards,
>
> Andy
Hello,
it works ! thanks Andy. I did this:
########
f_sources.addStep(Test())
f_sources.addStep(DistFileUpload(slavesrc="func_test_output.xml",
masterdest=WithProperties("~/public_html/func_test_output-%s-%s.xml",
"buildnumber", "buildername")))
########
the Test() step generated func_test_output.xml.
########
import os
from buildbot.steps.transfer import FileUpload
class DistFileUpload(FileUpload):
def __init__(self, slavesrc, masterdest,
workdir=None, maxsize=None, blocksize=16*1024, mode=None,
**kwargs):
FileUpload.__init__(self, slavesrc, masterdest,
workdir, maxsize, blocksize, mode,
**kwargs)
def finished(self, result):
properties = self.build.getProperties()
masterdest = properties.render(self.masterdest)
masterdest = os.path.basename(masterdest)
url = "http://buildbot:8010/%s" % masterdest
self.addURL("func_test_ouput", url)
return FileUpload.finished(self, result)
########
More information about the devel
mailing list