我在Jenkins以Maven方式驱动selenium web驱动程序自动化脚本。 我使用EnvInject插件在作业级别设置一些环境变量 获取'将环境变量注入构建过程'选 在属性内容中输入环境变量,如
jenkins_productType=offering
jenkins_env=UAT
jenkins_browser=firefox
jenkins_locale=en_US
然后启动构建,我从控制台获取日志
[EnvInject] - Loading node environment variables.
[EnvInject] - Preparing an environment for the build.
[EnvInject] - Keeping Jenkins system variables.
[EnvInject] - Keeping Jenkins build variables.
[EnvInject] - Injecting contributions.
Building in workspace C:\CIEnv_Jenkins\jobs\SCWDailyRegression_BasedOnMaven\workspace
[EnvInject] - Executing scripts and injecting environment variables after the SCM step.
[EnvInject] - Injecting as environment variables the properties content
jenkins_productType=offering
jenkins_env=UAT
jenkins_browser=firefox
jenkins_locale=en_US
[EnvInject] - Variables injected successfully.
我希望我可以通过java在Selenium Web驱动程序脚本中获取这些环境变量,例如
Boolean localSetting = System.getenv().containsKey("jenkins_locale");
我总是将localSetting设为false,这意味着没有设置这样的环境变量。 谁能帮我吗?非常感谢。