private EnvVars getEnvVars(DescribableList<NodeProperty<?>, NodePropertyDescriptor> dl) { final EnvironmentVariablesNodeProperty evnp = dl.get(EnvironmentVariablesNodeProperty.class); if (evnp == null) { return null; } return evnp.getEnvVars(); }
private EnvVars getEnvVars(DescribableList<NodeProperty<?>, NodePropertyDescriptor> dl) { final EnvironmentVariablesNodeProperty evnp = dl.get(EnvironmentVariablesNodeProperty.class); if (evnp == null) { return null; } return evnp.getEnvVars(); }
static String getUrlWithoutRevision( String remoteUrlPossiblyWithRevision) { String remoteUrlWithoutRevision = remoteUrlPossiblyWithRevision; if (Hudson.getInstance() != null) { for (NodeProperty n: Hudson.getInstance().getGlobalNodeProperties()) { EnvironmentVariablesNodeProperty gnp = (EnvironmentVariablesNodeProperty)n; for (Entry e : gnp.getEnvVars().entrySet()) { if (remoteUrlWithoutRevision.contains("${" + e.getKey().toString() + "}")) { remoteUrlWithoutRevision = remoteUrlWithoutRevision.replace("${" + e.getKey().toString() + "}", e.getValue().toString()); } } } } int idx = remoteUrlWithoutRevision.lastIndexOf('@'); if (idx > 0) { String n = remoteUrlWithoutRevision.substring(idx + 1); SVNRevision r = SVNRevision.parse(n); if ((r != null) && (r.isValid())) { return remoteUrlWithoutRevision.substring(0, idx); } } return remoteUrlWithoutRevision; }
private List<String> lookForJavaHome(Node node) { List<String> ret = new ArrayList<>(); if(node != null && node.getNodeProperties() != null){ for (NodeProperty property : node.getNodeProperties()){ if(property instanceof EnvironmentVariablesNodeProperty){ EnvVars env = ((EnvironmentVariablesNodeProperty) property).getEnvVars(); if (env != null && env.containsKey(JAVA_HOME)) { ret.add(env.get(JAVA_HOME) + BIN_JAVA); } } } } return ret; }
public void buildEnvVars(AbstractBuild<?, ?> build, EnvVars env) { for (NodeProperty nodeProperty: Hudson.getInstance().getGlobalNodeProperties()) { if (nodeProperty instanceof EnvironmentVariablesNodeProperty) { env.overrideAll(((EnvironmentVariablesNodeProperty)nodeProperty).getEnvVars()); } } for (NodeProperty nodeProperty: Computer.currentComputer().getNode().getNodeProperties()) { if (nodeProperty instanceof EnvironmentVariablesNodeProperty) { env.overrideAll(((EnvironmentVariablesNodeProperty)nodeProperty).getEnvVars()); } } } }
if (nodeProperty instanceof EnvironmentVariablesNodeProperty) { EnvironmentVariablesNodeProperty variablesNodeProperty = (EnvironmentVariablesNodeProperty) nodeProperty; EnvVars envVars = variablesNodeProperty.getEnvVars(); EnvInjectEnvVars envInjectEnvVars = new EnvInjectEnvVars(logger); configNodeEnvVars.putAll(envVars); if (nodeProperty instanceof EnvironmentVariablesNodeProperty) { EnvironmentVariablesNodeProperty variablesNodeProperty = (EnvironmentVariablesNodeProperty) nodeProperty; EnvVars envVars = variablesNodeProperty.getEnvVars(); EnvInjectEnvVars envInjectEnvVars = new EnvInjectEnvVars(logger); configNodeEnvVars.putAll(envVars);
for (NodeProperty prop : list) { if (prop instanceof EnvironmentVariablesNodeProperty) { EnvVars env = ((EnvironmentVariablesNodeProperty)prop).getEnvVars(); if (env != null && env.containsKey("JAVA_HOME")) javas.add(env.get("JAVA_HOME") + "/bin/java");
globalPropertiesEnvVars.putAll(((EnvironmentVariablesNodeProperty) nodeProperty).getEnvVars());
currentEnvVars.putAll(((EnvironmentVariablesNodeProperty) nodeProperty).getEnvVars());
public static void setEnvironmentVariables(JenkinsRule j, Map<String, String> params) throws IOException { EnvironmentVariablesNodeProperty prop = new EnvironmentVariablesNodeProperty(); EnvVars envVars = prop.getEnvVars(); envVars.putAll(params); j.jenkins.getGlobalNodeProperties().add(prop); }
@Before public void configureCloud() throws Exception { cloud = setupCloud(this); createSecret(cloud.connect()); cloud.getTemplates().clear(); cloud.addTemplate(buildBusyboxTemplate("busybox")); // Agents running in Kubernetes (minikube) need to connect to this server, so localhost does not work 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(); }
.getGlobalNodeProperties() .get(hudson.slaves.EnvironmentVariablesNodeProperty.class) .getEnvVars() != null) { allOverrides .putAll(Jenkins .getGlobalNodeProperties() .get(hudson.slaves.EnvironmentVariablesNodeProperty.class) .getEnvVars());
.getAll(EnvironmentVariablesNodeProperty.class); if (envVarsNodePropertyList != null && envVarsNodePropertyList.size() != 0) { globalVars = envVarsNodePropertyList.get(0).getEnvVars();