[Buildbot-devel] Modifying shell commands at runtime

Tommy Kudirka tkdeaddovedonoteat at live.com
Wed Jul 8 20:57:09 UTC 2009


Hi,
I've got my buildbot setup with Perforce. I had two problems with the initial setup. The first was that buildbot didn't properly handle the revision number when a build was forced, which I fixed by putting the following code into shell.py:
class ShellCommand(LoggingBuildStep):    ...    def start(self):
        properties = self.build.getProperties()

        if self.command[0] == 'p4' and self.command.count('sync') != 0:            if self.command[-1][0] == '#' or self.command[-1][0] == '@':                self.command.pop()            if str(self.getProperty('revision')) == '' or str(self.getProperty('revision')) == 'None':                self.command.append('#head')            else:                self.command.append('@' + str(self.getProperty('revision')))        ...
However, I realized that this apparently modifies the command at the same level as master.cfg, and that my command was permanently modified for as long as the buildmaster was online (hence the first nested if statement that cleans the command to prevent things like "#head #head @3174 @3160 #head" as p4 sync arguments)
My second problem also involves shell commands. The buildbot is configured to build two release configurations of our project. I want buildbot to submit the changes to Perforce, but I want it to wait until both release configurations are built. They are both started from a scheduler that is triggered by a debug builder. Which release builder starts first is sometimes random, so I cannot rely on another trigger to start the other builder. The only way I've found to get around this is to write a short Python script that reads and writes a local file to determine whether or not both builds are ready for submission. I add a buildstep for both releases that executes a shell command that calls a batch file that submits the builds. I then put the following code right under the previous changes:
        ...        from bothBuildsReady import bothBuildsReady        if self.command[0] == 'call' and self.command[1] == 'C:/bothBuildsReady.bat':            if(bothBuildsReady(self.getProperty('platform'))):               pass            else:                self.command.pop()                warnings = []        ...
Since this permanently edits 'command', it worked properly once and then I started getting a "list index out of range" exception on the first if statement (if self.command[0] == 'call'...) and the build's err.html showed that 'command' was simply 'call' (not 'call C:/bothBuildsReady.bat')
In short, is there a way for me to modify shell commands as they are about to be executed? I tried moving and adapting the above code to buildstep.startCommand(), but just got more exceptions.
Thanks in advance,Tommy
_________________________________________________________________
Hotmail® has ever-growing storage! Don’t worry about storage limits. 
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://buildbot.net/pipermail/devel/attachments/20090708/c256e814/attachment.html>


More information about the devel mailing list