[Buildbot-devel] Modifying shell commands at runtime

Dustin J. Mitchell dustin at zmanda.com
Wed Jul 8 21:17:46 UTC 2009


On Wed, Jul 8, 2009 at 4:57 PM, Tommy
Kudirka<tkdeaddovedonoteat at live.com> wrote:
> 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)

Now *that* is a monkeypatch, and a not-very-effective-one at that.
Why would you try to rewrite the shell commands generated by the P4
class in the parent class?  Why not just modify the P4 class itself?

I really can't fathom what has driven you to edit shell.py for these problems.

By the way, I think your solution of using some on-disk indication
that both builds are finished is currently the best option.  Hopefully
we'll have some better build-coordination tools in 0.7.12.

Dustin

-- 
Open Source Storage Engineer
http://www.zmanda.com




More information about the devel mailing list