2

I need to alter the build environment variable for a build step. However the current environment parameter only replaces existing environment variables.

Does anybody know how I can get buildbot to append to the PATH environment variable rather than replace:

my_return.addStep(ShellCommand(command=["qmake", "{0}.pro".format(pro_name)],
                               env={'PATH': qt_path}))
Phil Hannent
  • 12,047
  • 17
  • 71
  • 118

2 Answers2

4

You can extend/append to the PATH environment variable by putting $PATH at the end of the existing value. Something like:

my_return.addStep(ShellCommand(command=["qmake", "{0}.pro".format(pro_name)],
                               env={'PATH': [qt_path, "${PATH}"]}))

More details at the buildbot documentation.

sk11
  • 1,779
  • 1
  • 17
  • 29
  • Is `${PATH}` going to be resolved to the value of `PATH` as it exists in the environment of the master process or as it exists in the environment of the slave? There's a difference. I did not see any clear information in the documentation. (By the way you've pointed your documentation link to a version of Buildbot that has not been released yet.) – Louis Aug 26 '15 at 10:32
  • 1
    My Windows buildslave was version 0.8.4 and it failed with an error "exceptions.TypeError: expected string or buffer", however once I upgraded to 0.8.12 the environment worked as expected. Thank you. – Phil Hannent Aug 26 '15 at 10:52
  • 1
    @Louis Since the `ShellCommand` is going to be executed on the slave, `PATH` environment variable is from the slave. I updated the doc link to the latest release. Thanks for pointing out. – sk11 Aug 26 '15 at 11:41
0

If you know what the path is for qmake why don't you just use the full path to the program as the first argument, instead of forcing the shell to look for it?

i.e. suppose qt_path is /home/qt/bin, just write

my_return.addStep(ShellCommand(command=["/home/qt/bin/qmake",
                                 "{0}.pro".format(pro_name)]))
holdenweb
  • 33,305
  • 7
  • 57
  • 77