简体   繁体   English

如何从测试用例中的jenkins获取环境变量列表

[英]How to get the list of the environment variable from the jenkins in the test case

I am creating a test case for a plugin, I want to fetch all the environment variables that are present on the current Jenkins server.我正在为插件创建一个测试用例,我想获取当前 Jenkins 服务器上存在的所有环境变量。 Can anyone tell me how to fetch all the environment variables from the Jenkins server?谁能告诉我如何从 Jenkins 服务器获取所有环境变量?

   public class VariableExistsConditionTest {

    @Rule public JenkinsRule j = new JenkinsRule(); 


     @Test
      public void someTest() throws IOException, InterruptedException {
         EnvironmentVariablesNodeProperty prop = new EnvironmentVariablesNodeProperty();
         EnvVars env = prop.getEnvVars();
         env.put("DEPLOY_TARGET", "staging");
         j.jenkins.getGlobalNodeProperties().add(prop);
        //Code to fetch the environment variables


}

To get all environment variables use获取所有环境变量使用

Map<String, String> env = System.getenv();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM