[Buildbot-devel] custom step - how to set when a step fail or pass (evaluateStat function?)
shiny knight
theshinyknight at me.com
Thu Mar 20 23:57:11 UTC 2014
I am writing a custom class, derived by the shellcommand class.
Basically I get my server data, which has info about how much a product has been enriched with various elements. I get the data file (which is a standard text file, tab delimited).
Now, what I would like to obtain, is to have the step to fail when the data file contains certain values, and pass when has some other values. So far the docs didn't help me to figure out how to do so.
Looking at the docs, I have an idea that there is a function to overwrite, that changes what results the step return....but I am basically shooting in the dark.
I see in the customization.html page of the docs, an example that mention FAILURE and WARNINGS, for a property called self.finished. I assume that this is how you tell the Buildbot that something has to fail or raise a warning?
The example show a snippet, where the check is done in a function called "evaluateStat (self, cmd)"
def evaluateStat(self, cmd):
if cmd.didFail():
self.step_status.setText(["File not found."])
self.finished(FAILURE)
return
s = cmd.updates["stat"][-1]
if not stat.S_ISDIR(s[stat.ST_MODE]):
self.step_status.setText(["'tis not a directory"])
self.finished(WARNINGS)
return
cmd = buildstep.RemoteCommand('glob', {'glob': self.dirname + '/*.pyc'})
d = self.runCommand(cmd)
d.addCallback(lambda res: self.evaluateGlob(cmd))
d.addErrback(self.failed)
return d
So if I subclass shellcommand, and add evaluateStat(...) as described above, will this override the step original logic and allow me to dictate how to set self.finished for the Warning and Error state? I also don't get where "cmd" is declared, what it does and what is returning; but I assume that doesn't matter, since it is the self.finished() that set the step final state as pass, fail or warning. Does it matter where I put the call to self.finished()?
I have already code that check the values, so all that I should do is to add in the if statements, the values that I want to use (unless I've got this wrong)
I also assume that any other case non specified in that function will result in a "Pass" state, so you don't need to specify it.
Am I on the right track, or did I got it wrong? I can't find anywhere an example that show how to change the pass/fail/warning state of a step, and a search on "evaluateStat" + buildbot on google returns nothing.
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://buildbot.net/pipermail/devel/attachments/20140320/b1f68d98/attachment.html>
More information about the devel
mailing list