Created
October 1, 2017 11:29
-
-
Save godfath3r/d16e1a0e5beebd912344d55fb9ae9709 to your computer and use it in GitHub Desktop.
Simple test for environmenta variable in jenkins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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