[Buildbot-devel] Using environment on the slave side

Roy S. Rapoport buildbot-devel at ols.inorganic.org
Thu Sep 28 21:54:07 UTC 2006


On Thu, Sep 28, 2006 at 11:29:46PM +0200, Mateusz Loskot wrote:
> I'd like to ask for some guidelines and possibilities regarding
> environment variables usage. Here is the story.
> 
> Buildmaster lives on machine A.
> Buildslaves are installed on separate matchines (X,Y,Z, etc.)
> and connect remotely.
> I set a requirement for all buildslave instances, to define environment
> variable BUILHOME - absolute path to buildslave directory.
> The idea is to make build steps working on all buildslaves,
> all machines and systems *without* much configuring them,
> just one env variable.

Mateusz, I had a very similar issue here -- our build management system is
actually managed as part of our build management system.  That means that
in order to actually invoke it, you need to know where the build management
system build directory is.  That directory's defined in the environment of
each buildslave, but of course may be different on a per-buildslave basis.

We solved this by allowing environmental variable interpolation -- so I've
got a buildstep, for example, that's defined thus: 

bf.addStep(step.ShellCommand, name = name, command = \
	"%(workdir)s/tare/head/nightly/copy_tarball" 
)

The patch to the slave code was minor -- here it is:

---
Index: buildbot/slave/commands.py
===================================================================
--- buildbot/slave/commands.py  (revision 74440)
+++ buildbot/slave/commands.py  (revision 74441)
@@ -314,12 +314,12 @@
             else:
                 # for posix, use /bin/sh. for other non-posix, well, doesn't
                 # hurt to try
-                argv = ['/bin/sh', '-c', self.command]
+                argv = ['/bin/sh', '-c', self.command % os.environ]
         else:
             if runtime.platformType  == 'win32':
                 argv = [os.environ['COMSPEC'], '/c'] + list(self.command)
             else:
-                argv = self.command
+                argv = (" ".join(self.command) % os.environ).split()
 
         # self.stdin is handled in ShellCommandPP.connectionMade
 
---

-roy




More information about the devel mailing list