public Boolean resolve(String name) { for (LabelAtom a : labels) if (a.getName().equals(name)) return true; return false; } });
public static LabelAtom findNearest(String name) { List<String> candidates = new ArrayList<String>(); for (LabelAtom a : Jenkins.getInstance().getLabelAtoms()) { candidates.add(a.getName()); } return get(EditDistance.findNearest(name, candidates)); }
private PollingResult pollWithWorkspace(TaskListener listener, SCM scm, R lb, @Nonnull FilePath ws, WorkspaceList l) throws InterruptedException, IOException { // if doing non-concurrent build, acquire a workspace in a way that causes builds to block for this workspace. // this prevents multiple workspaces of the same job --- the behavior of Hudson < 1.319. // // OTOH, if a concurrent build is chosen, the user is willing to create a multiple workspace, // so better throughput is achieved over time (modulo the initial cost of creating that many workspaces) // by having multiple workspaces Node node = lb.getBuiltOn(); Launcher launcher = ws.createLauncher(listener).decorateByEnv(getEnvironment(node,listener)); WorkspaceList.Lease lease = l.acquire(ws, !concurrentBuild); try { String nodeName = node != null ? node.getSelfLabel().getName() : "[node_unavailable]"; listener.getLogger().println("Polling SCM changes on " + nodeName); LOGGER.fine("Polling SCM changes of " + getName()); if (pollingBaseline==null) // see NOTE-NO-BASELINE above calcPollingBaseline(lb,launcher,listener); PollingResult r = scm.poll(this, launcher, ws, listener, pollingBaseline); pollingBaseline = r.remote; return r; } finally { lease.release(); } }
public Boolean resolve(String name) { for (LabelAtom a : labels) if (a.getName().equals(name)) return true; return false; } });
public Boolean resolve(String name) { for (LabelAtom a : labels) if (a.getName().equals(name)) return true; return false; } });
public Boolean resolve(String name) { for (LabelAtom a : labels) { if (a.getName().equals(name)) { return true; } } return false; } });
public Boolean resolve(String name) { for (LabelAtom a : labels) if (a.getName().equals(name)) return true; return false; } });
public Boolean resolve(String name) { for (LabelAtom a : labels) if (a.getName().equals(name)) return true; return false; } });
public String apply(Node node) { return node.getSelfLabel().getName(); } };
public Map<String, String> getLabelsMap() { Set<LabelAtom> labelSet = getLabelSet(); ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder(); if (!labelSet.isEmpty()) { for (LabelAtom label : labelSet) { builder.put(label == null ? DEFAULT_ID : "jenkins/" + label.getName(), "true"); } } return builder.build(); }
public String buildLabelCheckBox(LabelAtom la, LabelAxis instance) { return jsstr("<input type='checkbox' name='values' json='%s' ", Functions.htmlAttributeEscape(la.getName())) +String.format("+has(%s)+",jsstr(la.getName())) +jsstr("/><label class='attach-previous'>%s (%s)</label>", la.getName(),la.getDescription()); // '${h.jsStringEscape('<input type="checkbox" name="values" json="'+h.htmlAttributeEscape(l.name)+'" ')}'+has("${h.jsStringEscape(l.name)}")+'${h.jsStringEscape('/><label class="attach-previous">'+l.name+' ('+l.description+')</label>')}' } }
private List<String> getNodeNamesForLabelExpression(String labelExp) { List<String> nodeNames = new ArrayList<String>(); try { Label label = LabelExpression.parseExpression(labelExp); for (Node node : label.getNodes()) { nodeNames.add(node.getSelfLabel().getName()); } } catch (ANTLRException e) { LOGGER.log(Level.SEVERE, "failed to parse label [" + labelExp + "]", e); } return nodeNames; }
public static LabelAtom findNearest(String name) { List<String> candidates = new ArrayList<String>(); for (LabelAtom a : Jenkins.getInstance().getLabelAtoms()) { candidates.add(a.getName()); } return get(EditDistance.findNearest(name, candidates)); }
@Override public List<AbstractBuildParameters> getParameters(AbstractBuild<?, ?> build, TaskListener listener) { Computer[] nodes = Jenkins.getInstance().getComputers(); final PrintStream logger = listener.getLogger(); List<AbstractBuildParameters> params = Lists.newArrayList(); for(Computer c : nodes) { Node n = c.getNode(); if (n!=null && c.isOnline() && c.getNumExecutors()>0) { params.add(new NodeLabelBuildParameter("label", n.getSelfLabel().getName())); logger.println("trigger build on "+n.getDisplayName() +" ("+n.getSelfLabel().getName()+")"); } } return params; }
} else { for (Node node : nodes) { final String nodeSelfLabel = node.getSelfLabel().getName(); if (ignoreOfflineNodes) { if(NodeUtil.isNodeOnline(nodeSelfLabel)) {
private PollingResult pollWithWorkspace(TaskListener listener, SCM scm, R lb, @Nonnull FilePath ws, WorkspaceList l) throws InterruptedException, IOException { // if doing non-concurrent build, acquire a workspace in a way that causes builds to block for this workspace. // this prevents multiple workspaces of the same job --- the behavior of Hudson < 1.319. // // OTOH, if a concurrent build is chosen, the user is willing to create a multiple workspace, // so better throughput is achieved over time (modulo the initial cost of creating that many workspaces) // by having multiple workspaces Node node = lb.getBuiltOn(); Launcher launcher = ws.createLauncher(listener).decorateByEnv(getEnvironment(node,listener)); WorkspaceList.Lease lease = l.acquire(ws, !concurrentBuild); try { String nodeName = node != null ? node.getSelfLabel().getName() : "[node_unavailable]"; listener.getLogger().println("Polling SCM changes on " + nodeName); LOGGER.fine("Polling SCM changes of " + getName()); if (pollingBaseline==null) // see NOTE-NO-BASELINE above calcPollingBaseline(lb,launcher,listener); PollingResult r = scm.poll(this, launcher, ws, listener, pollingBaseline); pollingBaseline = r.remote; return r; } finally { lease.release(); } }
/** * Returns a list of auto completion candidates. * * @return candidates */ public AutoCompletionCandidates doAutoCompleteLabel() { AutoCompletionCandidates candidates = new AutoCompletionCandidates(); List<Node> masterNodeList = Jenkins.getInstance().getNodes(); for (Node node : masterNodeList) { try { for (LabelAtom atom : Label.parseExpression(node.getLabelString()).listAtoms()) { candidates.add(atom.getName()); } } catch (ANTLRException e) { // invalid expression, skipped } } return candidates; }