I have buildbot configured, which has docker workers which in turn execute python script. The problem I encountered is worker seems to ignore new environment variable I am trying to add. in the master.cfg
I add:
f = util.BuildFactory()
f.addStep(steps.ShellCommand(
command=['python3', '/home/script.py'], name='Step1',
env={'VAR1': 'var1',
'NEW_VAR': 'new_var',
'VAR2': 'var2'}))
script.py
the uses os.environ['NEW_VAR']
(The same way as VAR1
and VAR2
)
However, after the buildbot prepares the worker and starts Step1 execution I see all environment variables including VAR1
and VAR2
but in the same output I get following error:
Traceback (most recent call last):
File "/home/script.py", line 11, in <module>
new_var = os.environ['NEW_VAR']
File "/usr/lib/python3.8/os.py", line 675, in __getitem__
raise KeyError(key) from None
KeyError: 'NEW_VAR'
After I made changes to the master.cfg
file I restarted the buildbot so I expect it to pick up the changes, but it seems to ignore them.
Any help is much appreciated.
Right after I added the last step to the build factory I checked the factory steps by adding:
for step in f.__dict__['steps']:
print(step.__dict__)
I see my NEW_VAR
there
{'factory': <class 'buildbot.steps.shell.ShellCommand'>,
'args': (),
'kwargs': {'command': ['python3', '/home/script.py'],
'name': 'Step1',
'env': {'VAR1': 'var1',
'NEW_VAR': 'new_var',
'VAR2': 'var2'}}}
But for some reason the NEW_VAR
is not picked up from environment when the builder is executing script.py