Skip to content

Instantly share code, notes, and snippets.

@godfath3r
Created October 1, 2017 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save godfath3r/d16e1a0e5beebd912344d55fb9ae9709 to your computer and use it in GitHub Desktop.
Save godfath3r/d16e1a0e5beebd912344d55fb9ae9709 to your computer and use it in GitHub Desktop.
Simple test for environmenta variable in jenkins
@Issue("JENKINS-16255")
@Test
public void environmentalVariables() throws Exception{
Map<String, String> env = new HashMap<>();
env.put("http_proxy", "http://www.test.com");
env.put("HTTP_PROXY", "http://www.test1.com");
Slave slave = rule.createSlave(new EnvVars(env));
FreeStyleProject project = rule.createFreeStyleProject();
final CommandInterpreter script = Functions.isWindows()
? new BatchFile("echo %http_proxy%;echo %HTTP_PROXY%")
: new Shell("echo ${http_proxy};echo ${HTTP_PROXY}")
;
project.getBuildersList().add(script);
project.setAssignedNode(slave.getComputer().getNode());
FreeStyleBuild build = project.scheduleBuild2(0).get();
rule.assertLogContains(String.format("echo %s", env.get("http_proxy")), build);
rule.assertLogContains(String.format("echo %s", env.get("HTTP_PROXY")), build);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment