使用python脚本访问TeamCity环境变量

时间:2021-08-11 23:20:34

I am using TeamCity to test my code. I am using command line from TC and I am running a python test suite that tests the code.

我正在使用TeamCity来测试我的代码。我正在使用TC的命令行,我正在运行一个测试代码的python测试套件。

I defined an environment variable (named "Server") and gave it a value ("production") and I want to pass it in a way that my python script will be able to access it and save it's value in the code.

我定义的环境变量(名为“服务器”),并把它的值(“生产”),我想将它传递的方式,我的Python脚本将能够访问它,并保存它的代码值。

I tried looking in TC documentation as well in Python's documentation and I couldn't find it.

我尝试在Python的文档中查看TC文档,但我找不到它。

I will appreciate your help.

我将感谢你的帮助。

1 个解决方案

#1


Probably you should use os.environ

可能你应该使用os.environ

assert os.environ['Server'] == 'production'

#1


Probably you should use os.environ

可能你应该使用os.environ

assert os.environ['Server'] == 'production'