[Buildbot-devel] custom checkout command run in shell

Brian Warner warner-buildbot at lothar.com
Sun Nov 26 08:11:11 UTC 2006


f at rtfs.org writes:

>> f1.source = s(step.ShellCommand, command=[ r'C:\Python24\pyton.exe'
>>                                          , C:\clearcase_checkout.py
>>                                          , WithProperties("%s",
>> "revision")
>>                                          ])
>
> But I still have some trouble. I force the builds by running the command:
>
>         cmd = "buildbot sendchange --master="+change['master']+"

> Which works great, and the log says that the revision is set.
> But still I only get the empty string for the WithProperties("%s",
> "revision")
> ind the shell command.
>
> Any ideas how I can get the revision string?

The problem here is that it turns out that the 'revision' property is only
set when you force a build of a specific revision. If the build is triggered
because of changes, it doesn't get set. The reason for this is that there
could be multiple Changes that go into a build: the source-checkout step
(like source.CVS or source.SVN) is responsible for using all of the Changes
(and the revision numbers inside them) to decide what revision to use for the
checkout. This keeps all the per-VC information isolated to the
source-checkout step, but it also means that you can't use the "revision"
property the way you want to.

There is another property, the "got_revision" property, which is set to
whatever revision was obtained by the source-checkout step, regardless of
whether the build occurred because of Changes or because someone forced a
build. But this won't help your situation either, because you don't have a
source-checkout step to provide it.

I'd suggest creating a ShellCommand subclass that looks at the list of
Changes that went into the build and modifies the command you're running
accordingly. Something roughly like this:

class MyCheckout(ShellCommand):
    def start(self):
        ss = self.build.getSourceStamp()
        if s.revision:
            revision = s.revision
        elif s.changes:
            revision = figureOutWhatRevisionToUse(s.changes)
        self.command = [ r'C:\Python24\python.exe',
                         r'C:\clearcase_checkout.py',
                         revision ]
        ShellCommand.start(self)

        

hope that helps,
 -Brian




More information about the devel mailing list