[Buildbot-devel] Using slave name in the file name of a uploaded file

John Saxton saxton at apple.com
Wed Feb 13 03:07:10 UTC 2008


On Feb 12, 2008, at 1:06 PM, Wang, Yu wrote:
> I need to upload a file from each slave and would like to name the  
> uploaded file using the corresponding slave name.  In my builders,  
> I have slavenames defined, but the factory is generic for all  
> builders (slaves).  Is there a way to reference the slavename in  
> factory definition such as in: addStep(FileUpload, …) so that I can  
> put all uploaded files in one folder on the master and name each  
> file using the corresponding slave name?

You could subclass FileUpload to add WithProperties support.  You can  
do this right from your master.cfg:

from buildbot.steps.transfer import FileUpload
from buildbot.steps.shell import WithProperties

class FlexibleFileUpload(FileUpload):
     """Enhances FileUpload to add "WithProperties" support on  
filename arguments"""

     name='upload'

     def _interpolateFileName(self, fileName):
         if isinstance(fileName, WithProperties):
             return fileName.render(self.build)
         return fileName

     def start(self):
         self.slavesrc = self._interpolateFileName(self.slavesrc)
         self.masterdest = self._interpolateFileName(self.masterdest)
         FileUpload.start(self)

[...and, later in your master.cfg...]

f.addStep(FlexibleFileUpload(slavesrc=['somefile'],  
masterdest=WithProperties("somefile-%(slavename)s")))

-John
P.S. I tried this on my slightly hacked-up copy of 0.7.6 and it  
worked.  I see from another thread that you're running 0.7.5, so  
YMMV.  You'll certainly need to change the way I called addStep back  
to the form that 0.7.5 used.





More information about the devel mailing list