简体   繁体   中英

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. Can anyone tell me how to fetch all the environment variables from the Jenkins server?

   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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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