@Before
public void configureCloud() throws Exception {
cloud = setupCloud(this);
createSecret(cloud.connect());
cloud.getTemplates().clear();
cloud.addTemplate(buildBusyboxTemplate("busybox"));
URL url = r.getURL();
String hostAddress = System.getProperty("jenkins.host.address");
if (hostAddress == null) {
hostAddress = InetAddress.getLocalHost().getHostAddress();
}
URL nonLocalhostUrl = new URL(url.getProtocol(), hostAddress, url.getPort(),
url.getFile());
JenkinsLocationConfiguration.get().setUrl(nonLocalhostUrl.toString());
r.jenkins.clouds.add(cloud);
DescribableList<NodeProperty<?>, NodePropertyDescriptor> list = r.jenkins.getGlobalNodeProperties();
EnvironmentVariablesNodeProperty newEnvVarsNodeProperty = new hudson.slaves.EnvironmentVariablesNodeProperty();
list.add(newEnvVarsNodeProperty);
EnvVars envVars = newEnvVarsNodeProperty.getEnvVars();
envVars.put("GLOBAL", "GLOBAL");
envVars.put("JAVA_HOME_X", "java-home-x");
r.jenkins.save();
}