@DataBoundConstructor public EnvironmentVariablesNodeProperty(List<Entry> env) { this.envVars = toMap(env); }
private EnvVars getEnvVars(DescribableList<NodeProperty<?>, NodePropertyDescriptor> dl) { final EnvironmentVariablesNodeProperty evnp = dl.get(EnvironmentVariablesNodeProperty.class); if (evnp == null) { return null; } return evnp.getEnvVars(); }
public void set() throws IOException { List<EnvironmentVariablesNodeProperty.Entry> entries = new ArrayList<>(env.size()); for (Map.Entry<String, String> entry : env.entrySet()) { entries.add(new EnvironmentVariablesNodeProperty.Entry(entry.getKey(), entry.getValue())); } EnvironmentVariablesNodeProperty newProperty = new EnvironmentVariablesNodeProperty(entries); DescribableList<NodeProperty<?>, NodePropertyDescriptor> nodeProperties = agent.getNodeProperties(); nodeProperties.replace(newProperty); }
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); }
private EnvVars getEnvVars(DescribableList<NodeProperty<?>, NodePropertyDescriptor> dl) { final EnvironmentVariablesNodeProperty evnp = dl.get(EnvironmentVariablesNodeProperty.class); if (evnp == null) { return null; } return evnp.getEnvVars(); }
public JCloudsSlave( @Nonnull ProvisioningActivity.Id id, @Nonnull Server metadata, @Nonnull String labelString, @Nonnull SlaveOptions slaveOptions ) throws IOException, Descriptor.FormException { super( metadata.getName(), null, slaveOptions.getFsRoot(), slaveOptions.getNumExecutors(), Mode.NORMAL, labelString, null, new JCloudsRetentionStrategy(), Collections.singletonList(new EnvironmentVariablesNodeProperty( new EnvironmentVariablesNodeProperty.Entry("OPENSTACK_PUBLIC_IP", Openstack.getPublicAddress(metadata)) )) ); this.cloudName = id.getCloudName(); // TODO deprecate field this.provisioningId = id; this.options = slaveOptions; this.nodeId = metadata.getId(); this.cache = makeCache(); setLauncher(new JCloudsLauncher(getLauncherFactory().createLauncher(this))); }
@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(); }
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; }
? new AzureVMAgentSSHLauncher() : new JNLPLauncher(), retentionStrategy, Arrays.asList(new EnvironmentVariablesNodeProperty( new EnvironmentVariablesNodeProperty.Entry("FQDN", fqdn) )),
@DataBoundConstructor public EnvironmentVariablesNodeProperty(List<Entry> env) { this.envVars = toMap(env); }
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; }
@BeforeClass public static void setUpAgent() throws Exception { s = j.createOnlineSlave(); s.setNumExecutors(4); s.setLabelString("some-label docker test"); s.getNodeProperties().add(new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("ONAGENT", "true"))); }
@DataBoundConstructor public EnvironmentVariablesNodeProperty(List<Entry> env) { this.envVars = toMap(env); }
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()); } } } }
@BeforeClass public static void setUpAgent() throws Exception { s = j.createOnlineSlave(); s.setLabelString("some-label docker"); s.getNodeProperties().add(new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("ONAGENT", "true"), new EnvironmentVariablesNodeProperty.Entry("WHICH_AGENT", "first"))); s.setNumExecutors(2); s2 = j.createOnlineSlave(); s2.setLabelString("other-docker"); s2.getNodeProperties().add(new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("ONAGENT", "true"), new EnvironmentVariablesNodeProperty.Entry("WHICH_AGENT", "second"))); //setup credentials for docker registry CredentialsStore store = CredentialsProvider.lookupStores(j.jenkins).iterator().next(); password = System.getProperty("docker.password"); if(password != null) { UsernamePasswordCredentialsImpl globalCred = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "dockerhub", "real", "jtaboada", password); store.addCredentials(Domain.global(), globalCred); } }
@DataBoundConstructor public EnvironmentVariablesNodeProperty(List<Entry> env) { this.envVars = toMap(env); }
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);
@BeforeClass public static void setUpAgent() throws Exception { s = j.createOnlineSlave(); s.setLabelString("some-label docker"); s.getNodeProperties().add( new EnvironmentVariablesNodeProperty( new EnvironmentVariablesNodeProperty.Entry("HAS_BACKSLASHES", "C:\\Windows"), new EnvironmentVariablesNodeProperty.Entry("FOO", "OTHER"))); }
@DataBoundConstructor public EnvironmentVariablesNodeProperty(List<Entry> env) { this.envVars = toMap(env); }
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");