/** * Return the possibly empty tag cloud for the labels of this node. */ public TagCloud<LabelAtom> getLabelCloud() { return new TagCloud<LabelAtom>(getAssignedLabels(),new WeightFunction<LabelAtom>() { public float weight(LabelAtom item) { return item.getTiedJobCount(); } }); } /**
public final boolean matches(Node n) { return matches(n.getAssignedLabels()); }
@Exported public Set<LabelAtom> getAssignedLabels() { Node node = getNode(); return (node != null) ? node.getAssignedLabels() : Collections.EMPTY_SET; }
slave.getAssignedLabels(); getAssignedLabels();
@Override public void buildEnvironmentFor(Job j, EnvVars env, TaskListener listener) throws IOException, InterruptedException { Jenkins jenkins = Jenkins.getInstance(); String rootUrl = jenkins.getRootUrl(); if(rootUrl!=null) { env.put("JENKINS_URL", rootUrl); env.put("HUDSON_URL", rootUrl); // Legacy compatibility env.put("JOB_URL", rootUrl+j.getUrl()); } String root = jenkins.getRootDir().getPath(); env.put("JENKINS_HOME", root); env.put("HUDSON_HOME", root); // legacy compatibility Thread t = Thread.currentThread(); if (t instanceof Executor) { Executor e = (Executor) t; env.put("EXECUTOR_NUMBER", String.valueOf(e.getNumber())); if (e.getOwner() instanceof MasterComputer) { env.put("NODE_NAME", "master"); } else { env.put("NODE_NAME", e.getOwner().getName()); } Node n = e.getOwner().getNode(); if (n != null) env.put("NODE_LABELS", Util.join(n.getAssignedLabels(), " ")); } } }
public Set<LabelAtom> superGetAssignedLabels() { return super.getAssignedLabels(); }
/** * Return the possibly empty tag cloud for the labels of this node. */ public TagCloud<LabelAtom> getLabelCloud() { return new TagCloud<LabelAtom>(getAssignedLabels(),new WeightFunction<LabelAtom>() { public float weight(LabelAtom item) { return item.getTiedJobs().size(); } }); } /**
/** * Return the possibly empty tag cloud for the labels of this node. */ public TagCloud<LabelAtom> getLabelCloud() { return new TagCloud<LabelAtom>(getAssignedLabels(),new WeightFunction<LabelAtom>() { public float weight(LabelAtom item) { return item.getTiedJobCount(); } }); } /**
/** * Return the possibly empty tag cloud for the labels of this node. */ public TagCloud<LabelAtom> getLabelCloud() { return new TagCloud<LabelAtom>(getAssignedLabels(), new WeightFunction<LabelAtom>() { public float weight(LabelAtom item) { return item.getTiedJobs().size(); } }); }
/** * Return the possibly empty tag cloud for the labels of this node. */ public TagCloud<LabelAtom> getLabelCloud() { return new TagCloud<LabelAtom>(getAssignedLabels(),new WeightFunction<LabelAtom>() { public float weight(LabelAtom item) { return item.getTiedJobs().size(); } }); } /**
/** * Return the possibly empty tag cloud for the labels of this node. */ public TagCloud<LabelAtom> getLabelCloud() { return new TagCloud<LabelAtom>(getAssignedLabels(),new WeightFunction<LabelAtom>() { public float weight(LabelAtom item) { return item.getTiedJobs().size(); } }); } /**
public final boolean matches(Node n) { return matches(n.getAssignedLabels()); }
public final boolean matches(Node n) { return matches(n.getAssignedLabels()); }
public final boolean matches(Node n) { return matches(n.getAssignedLabels()); }
public final boolean matches(Node n) { return matches(n.getAssignedLabels()); }
public final boolean matches(Node n) { return matches(n.getAssignedLabels()); }
/** * Remove labels from a slave */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void doRemoveSlaveLabels(StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String secret, @QueryParameter String labels) throws IOException { if (!getSwarmSecret().equals(secret)) { rsp.setStatus(SC_FORBIDDEN); return; } Node nn = getNodeByName(name, rsp); if (nn == null) { return; } String sCurrentLabels = nn.getLabelString(); List<String> lCurrentLabels = Arrays.asList(sCurrentLabels.split("\\s+")); HashSet<String> hs = new HashSet<>(lCurrentLabels); List<String> lBadLabels = Arrays.asList(labels.split("\\s+")); hs.removeAll(lBadLabels); nn.setLabelString(hashSetToString(hs)); nn.getAssignedLabels(); normalResponse(req, rsp, nn.getLabelString()); }
/** * Adds labels to a slave. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void doAddSlaveLabels(StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String secret, @QueryParameter String labels) throws IOException{ if (!getSwarmSecret().equals(secret)) { rsp.setStatus(SC_FORBIDDEN); return; } Node nn = getNodeByName(name, rsp); if (nn == null) { return; } String sCurrentLabels = nn.getLabelString(); List<String> lCurrentLabels = Arrays.asList(sCurrentLabels.split("\\s+")); HashSet<String> hs = new HashSet<>(lCurrentLabels); List<String> lNewLabels = Arrays.asList(labels.split("\\s+")); hs.addAll(lNewLabels); nn.setLabelString(hashSetToString(hs)); nn.getAssignedLabels(); normalResponse(req, rsp, nn.getLabelString()); }
@Override @Exported public Set<LabelAtom> getAssignedLabels() { initPython(); if (pexec.isImplemented(4)) { return (Set) pexec.execPython("get_assigned_labels"); } else { return super.getAssignedLabels(); } }
@Override public void buildEnvironmentFor(Job j, EnvVars env, TaskListener listener) throws IOException, InterruptedException { Jenkins jenkins = Jenkins.getInstance(); String rootUrl = jenkins.getRootUrl(); if(rootUrl!=null) { env.put("JENKINS_URL", rootUrl); env.put("HUDSON_URL", rootUrl); // Legacy compatibility env.put("JOB_URL", rootUrl+j.getUrl()); } String root = jenkins.getRootDir().getPath(); env.put("JENKINS_HOME", root); env.put("HUDSON_HOME", root); // legacy compatibility Thread t = Thread.currentThread(); if (t instanceof Executor) { Executor e = (Executor) t; env.put("EXECUTOR_NUMBER", String.valueOf(e.getNumber())); if (e.getOwner() instanceof MasterComputer) { env.put("NODE_NAME", "master"); } else { env.put("NODE_NAME", e.getOwner().getName()); } Node n = e.getOwner().getNode(); if (n != null) env.put("NODE_LABELS", Util.join(n.getAssignedLabels(), " ")); } } }