/** * Creates an environment variable override to be used for launching processes on this node. * * @see ProcStarter#envs(Map) * @since 1.489 */ public @Nonnull EnvVars buildEnvironment(@Nonnull TaskListener listener) throws IOException, InterruptedException { EnvVars env = new EnvVars(); Node node = getNode(); if (node==null) return env; // bail out for (NodeProperty nodeProperty: Jenkins.getInstance().getGlobalNodeProperties()) { nodeProperty.buildEnvVars(env,listener); } for (NodeProperty nodeProperty: node.getNodeProperties()) { nodeProperty.buildEnvVars(env,listener); } // TODO: hmm, they don't really belong String rootUrl = Jenkins.getInstance().getRootUrl(); if(rootUrl!=null) { env.put("HUDSON_URL", rootUrl); // Legacy. env.put("JENKINS_URL", rootUrl); } return env; }
/** * Called by the {@link Node} to help determine whether or not it should * take the given task. Individual properties can return a non-null value * here if there is some reason the given task should not be run on its * associated node. By default, this method returns <code>null</code>. * * @since 1.413 */ public CauseOfBlockage canTake(BuildableItem item) { return canTake(item.task); // backward compatible behaviour }
/** * List up all {@link NodePropertyDescriptor}s that are applicable for the * given project. */ public static List<NodePropertyDescriptor> for_(Node node) { return NodePropertyDescriptor.for_(all(),node); } }
public List<NodePropertyDescriptor> getNodePropertyDescriptors() { return NodeProperty.for_(this); }
public Environment superSetUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { return super.setUp(build, launcher, listener); }
public NodeProperty<?> reconfigure(StaplerRequest req, JSONObject form) throws FormException { return form==null ? null : getDescriptor().newInstance(req, form); }
private static NodeProperty updateWithNode(NodeProperty prop, DumbSlave agent) { prop.setNode(agent); return prop; }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { try { Jenkins j = Jenkins.get(); JSONObject np = json.getJSONObject("globalNodeProperties"); if (!np.isNullObject()) { j.getGlobalNodeProperties().rebuild(req, np, NodeProperty.for_(j)); } return true; } catch (IOException e) { throw new FormException(e,"globalNodeProperties"); } } }
@Override public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { initPython(); if (pexec.isImplemented(4)) { return (Environment) pexec.execPython("set_up", build, launcher, listener); } else { return super.setUp(build, launcher, listener); } }
public NodePropertyDescriptor superGetDescriptor() { return super.getDescriptor(); }
public void superSetNode(N node) { super.setNode(node); }
CauseOfBlockage c = prop.canTake(item); if (c!=null) return c;
public List<NodePropertyDescriptor> getNodePropertyDescriptors() { return NodeProperty.for_(this); }
@Test @Issue("Issue #173") @ConfiguredWithCode("SetEnvironmentVariable.yml") public void shouldSetEnvironmentVariable() throws Exception { final DescribableList<NodeProperty<?>, NodePropertyDescriptor> properties = Jenkins.getInstance().getNodeProperties(); EnvVars env = new EnvVars(); for (NodeProperty<?> property : properties) { property.buildEnvVars(env, TaskListener.NULL); } assertEquals("BAR", env.get("FOO")); }
@Override public Object onConvert(Type targetType, Class targetTypeErasure, Object jsonSource) { if (jsonForProperties != jsonSource) { return old.get().onConvert(targetType, targetTypeErasure, jsonSource); } try { DescribableList<NodeProperty<?>, NodePropertyDescriptor> tmp = new DescribableList<NodeProperty<?>, NodePropertyDescriptor>(Saveable.NOOP,getNodeProperties().toList()); tmp.rebuild(req, jsonForProperties, NodeProperty.all()); return tmp.toList(); } catch (FormException e) { throw new IllegalArgumentException(e); } catch (IOException e) { throw new IllegalArgumentException(e); } } }));
public NodeProperty<?> reconfigure(StaplerRequest req, JSONObject form) throws FormException { return form==null ? null : getDescriptor().newInstance(req, form); }
@Override public void setNode(N node) { initPython(); if (pexec.isImplemented(0)) { pexec.execPythonVoid("set_node", node); } else { super.setNode(node); } }
/** * Called by the {@link Node} to help determine whether or not it should * take the given task. Individual properties can return a non-null value * here if there is some reason the given task should not be run on its * associated node. By default, this method returns <code>null</code>. * * @since 1.413 */ public CauseOfBlockage canTake(BuildableItem item) { return canTake(item.task); // backward compatible behaviour }
public List<NodePropertyDescriptor> getNodePropertyDescriptors() { return NodeProperty.for_(this); }