/** * Set of labels relevant to this job. * * This method is used to determine what agents are relevant to jobs, for example by {@link View}s. * It does not affect the scheduling. This information is informational and the best-effort basis. * * @since 1.456 * @return * Minimally it should contain {@link #getAssignedLabel()}. The set can contain null element * to correspond to the null return value from {@link #getAssignedLabel()}. */ public Set<Label> getRelevantLabels() { return Collections.singleton(getAssignedLabel()); }
/** * Returns projects that are tied on this node. */ @Exported public List<AbstractProject> getTiedJobs() { List<AbstractProject> r = new ArrayList<AbstractProject>(); for (AbstractProject<?,?> p : Jenkins.getInstance().allItems(AbstractProject.class)) { if(p instanceof TopLevelItem && this.equals(p.getAssignedLabel())) r.add(p); } Collections.sort(r, Items.BY_FULL_NAME); return r; }
private WorkspaceOfflineReason workspaceOffline(R build) throws IOException, InterruptedException { FilePath ws = build.getWorkspace(); Label label = getAssignedLabel(); if (isAllSuitableNodesOffline(build)) { Collection<Cloud> applicableClouds = label == null ? Jenkins.getInstance().clouds : label.getClouds(); return applicableClouds.isEmpty() ? WorkspaceOfflineReason.all_suitable_nodes_are_offline : WorkspaceOfflineReason.use_ondemand_slave; } if (ws==null || !ws.exists()) { return WorkspaceOfflineReason.nonexisting_workspace; } Node builtOn = build.getBuiltOn(); if (builtOn == null) { // node built-on doesn't exist anymore return WorkspaceOfflineReason.builton_node_gone; } if (builtOn.toComputer() == null) { // node still exists, but has 0 executors - o.s.l.t. return WorkspaceOfflineReason.builton_node_no_executors; } return null; }
Label label = getAssignedLabel(); if (label != null && label.isSelfLabel()) {
Label label = getAssignedLabel(); List<Node> allNodes = Jenkins.getInstance().getNodes();
/** * Set of labels relevant to this job. * * This method is used to determine what agents are relevant to jobs, for example by {@link View}s. * It does not affect the scheduling. This information is informational and the best-effort basis. * * @since 1.456 * @return * Minimally it should contain {@link #getAssignedLabel()}. The set can contain null element * to correspond to the null return value from {@link #getAssignedLabel()}. */ public Set<Label> getRelevantLabels() { return Collections.singleton(getAssignedLabel()); }
/** * Returns the label if any to poll */ private Label getTargetLabel(XTriggerLog log) { AbstractProject p = (AbstractProject) job; Label assignedLabel = p.getAssignedLabel(); if (assignedLabel != null) { log.info(String.format("Trying to find an eligible node with the assigned project label %s.", assignedLabel)); return assignedLabel; } return null; }
/** * Returns projects that are tied on this node. */ @Exported public List<AbstractProject> getTiedJobs() { List<AbstractProject> r = new ArrayList<AbstractProject>(); for (AbstractProject<?,?> p : Jenkins.getInstance().allItems(AbstractProject.class)) { if(p instanceof TopLevelItem && this.equals(p.getAssignedLabel())) r.add(p); } Collections.sort(r, Items.BY_FULL_NAME); return r; }
/** * Returns projects that are tied on this node. */ @Exported public List<AbstractProject> getTiedJobs() { List<AbstractProject> r = new ArrayList<AbstractProject>(); for( AbstractProject p : Util.filter(Hudson.getInstance().getItems(),AbstractProject.class) ) { if(this.equals(p.getAssignedLabel())) r.add(p); } return r; }
@Override public Label getAssignedLabel() { // Really would like to run on the exact node that the promoted build ran on, // not just the same label.. but at least this works if job is tied to one node: if (assignedLabel == null) return getOwner().getAssignedLabel(); return JenkinsHelper.getInstance().getLabel(assignedLabel); }
/** * Returns projects that are tied on this node. */ @Exported public List<AbstractProject> getTiedJobs() { List<AbstractProject> r = new ArrayList<AbstractProject>(); for( AbstractProject p : Util.filter(Hudson.getInstance().getItems(),AbstractProject.class) ) { if(this.equals(p.getAssignedLabel())) r.add(p); } return r; }
/** * Returns projects that are tied on this node. */ @Exported public List<AbstractProject> getTiedJobs() { List<AbstractProject> r = new ArrayList<AbstractProject>(); for( AbstractProject p : Util.filter(Hudson.getInstance().getItems(),AbstractProject.class) ) { if(this.equals(p.getAssignedLabel())) r.add(p); } return r; }
if (item instanceof AbstractProject<?,?>) { AbstractProject<?,?> p = (AbstractProject<?, ?>) item; Label l = p.getAssignedLabel(); if (l != null) { labels.add(l);
/** * Set the default Slave Info Label if no Label is assigned to the {@link Item} * @param item */ private void setLabel(final Item item) { if (item instanceof AbstractProject) { AbstractProject<?, ?> job = (AbstractProject<?, ?>) item; LOGGER.fine("MesosListener.setLabel(), setting label"); Label label = job.getAssignedLabel(); try { if (label == null) { // No label assigned, override now LOGGER.log(Level.FINE, "No label assigned to job - " + job.getDisplayName() + ". Assigning a label now..."); label = getLabel(); if (label != null) { LOGGER.log(Level.INFO, "Assigned \"" + label.getName() + "\" to job \"" + job.getDisplayName() + "\""); job.setAssignedLabel(label); } } } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to assign label \"" + label + "\" to " + job.getDisplayName(), e); } } }
if (item instanceof AbstractProject<?,?>) { AbstractProject<?,?> p = (AbstractProject<?, ?>) item; Label l = p.getAssignedLabel(); if (l != null) { labels.add(l);
public List<Computer> getComputers() { Computer[] computers = Hudson.getInstance().getComputers(); if (!isFilterExecutors()) { return Arrays.asList(computers); } List<Computer> result = new ArrayList<Computer>(); boolean roam = false; HashSet<Label> labels = new HashSet<Label>(); for (Item item : getItems()) { if (item instanceof AbstractProject<?, ?>) { AbstractProject<?, ?> p = (AbstractProject<?, ?>) item; Label l = p.getAssignedLabel(); if (l != null) { labels.add(l); } else { roam = true; } } } for (Computer c : computers) { Node n = c.getNode(); if (n != null) { if (roam && n.getMode() == Mode.NORMAL || !Collections.disjoint(n.getAssignedLabels(), labels)) { result.add(c); } } } return result; }
if (item instanceof AbstractProject<?,?>) { AbstractProject<?,?> p = (AbstractProject<?, ?>) item; Label l = p.getAssignedLabel(); if (l != null) { labels.add(l);
/** * Returns projects that are tied on this node. */ @Exported public List<AbstractProject> getTiedJobs() { List<AbstractProject> r = new ArrayList<AbstractProject>(); for (AbstractProject p : Util.filter(Hudson.getInstance().getItems(), AbstractProject.class)) { if (this.equals(p.getAssignedLabel())) { r.add(p); } } for (MatrixProject p : Util.filter(Hudson.getInstance().getItems(), MatrixProject.class)) { for (Axis axis : p.getAxes()) { if (axis.getValues().contains(getName())){ r.add(p); } } } return r; }
private WorkspaceOfflineReason workspaceOffline(R build) throws IOException, InterruptedException { FilePath ws = build.getWorkspace(); Label label = getAssignedLabel(); if (isAllSuitableNodesOffline(build)) { Collection<Cloud> applicableClouds = label == null ? Jenkins.getInstance().clouds : label.getClouds(); return applicableClouds.isEmpty() ? WorkspaceOfflineReason.all_suitable_nodes_are_offline : WorkspaceOfflineReason.use_ondemand_slave; } if (ws==null || !ws.exists()) { return WorkspaceOfflineReason.nonexisting_workspace; } Node builtOn = build.getBuiltOn(); if (builtOn == null) { // node built-on doesn't exist anymore return WorkspaceOfflineReason.builton_node_gone; } if (builtOn.toComputer() == null) { // node still exists, but has 0 executors - o.s.l.t. return WorkspaceOfflineReason.builton_node_no_executors; } return null; }
Label label = getAssignedLabel(); List<Node> allNodes = Jenkins.getInstance().getNodes();