我正在为一个插件创建一个测试用例,我想获取当前Jenkins服务器上存在的所有环境变量。有人能告诉我如何从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
}
要获取所有环境变量,请使用
Map<String, String> env = System.getenv();