Next: , Previous: Transferring Strings, Up: Build Steps


4.11.8 Running Commands on the Master

Occasionally, it is useful to execute some task on the master, for example to create a directory, deploy a build result, or trigger some other centralized processing. This is possible, in a limited fashion, with the MasterShellCommand step.

This step operates similarly to a regular ShellCommand, but executes on the master, instead of the slave. To be clear, the enclosing Build object must still have a slave object, just as for any other step – only, in this step, the slave does not do anything.

In this example, the step renames a tarball based on the day of the week.

     from buildbot.steps.transfer import FileUpload
     from buildbot.steps.master import MasterShellCommand
     
     f.addStep(FileUpload(slavesrc="widgetsoft.tar.gz",
                          masterdest="/var/buildoutputs/widgetsoft-new.tar.gz"))
     f.addStep(MasterShellCommand(command="""
         cd /var/buildoutputs;
         mv widgetsoft-new.tar.gz widgetsoft-`date +%a`.tar.gz"""))

Note that, by default, this step passes a copy of the buildmaster's environment variables to the subprocess. To pass an explicit environment instead, add an env={..} argument.