hudson.model.AbstractProject.getAssignedLabel()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中hudson.model.AbstractProject.getAssignedLabel()方法的一些代码示例,展示了AbstractProject.getAssignedLabel()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractProject.getAssignedLabel()方法的具体详情如下:
包路径:hudson.model.AbstractProject
类名称:AbstractProject
方法名:getAssignedLabel

AbstractProject.getAssignedLabel介绍

[英]If this project is configured to be always built on this node, return that Node. Otherwise null.
[中]如果此项目配置为始终在此节点上生成,请返回该节点。否则为空。

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
 * 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());
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * 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;
}

代码示例来源:origin: jenkinsci/jenkins

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;
}

代码示例来源:origin: jenkinsci/jenkins

Label label = getAssignedLabel();
if (label != null && label.isSelfLabel()) {

代码示例来源:origin: jenkinsci/jenkins

Label label = getAssignedLabel();
List<Node> allNodes = Jenkins.getInstance().getNodes();

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * 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());
}

代码示例来源:origin: org.jenkins-ci.lib/xtrigger-lib

/**
 * 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;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * 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;
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * 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;
}

代码示例来源:origin: jenkinsci/promoted-builds-plugin

@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);
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * 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;
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * 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;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

if (item instanceof AbstractProject<?,?>) {
  AbstractProject<?,?> p = (AbstractProject<?, ?>) item;
  Label l = p.getAssignedLabel();
  if (l != null) {
    labels.add(l);

代码示例来源:origin: jenkinsci/mesos-plugin

/**
 * 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);
    }
  }
}

代码示例来源:origin: hudson/hudson-2.x

if (item instanceof AbstractProject<?,?>) {
  AbstractProject<?,?> p = (AbstractProject<?, ?>) item;
  Label l = p.getAssignedLabel();
  if (l != null) {
    labels.add(l);

代码示例来源:origin: org.eclipse.hudson/hudson-core

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;
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

if (item instanceof AbstractProject<?,?>) {
  AbstractProject<?,?> p = (AbstractProject<?, ?>) item;
  Label l = p.getAssignedLabel();
  if (l != null) {
    labels.add(l);

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * 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;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

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;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

Label label = getAssignedLabel();
List<Node> allNodes = Jenkins.getInstance().getNodes();

相关文章

微信公众号

最新文章

更多

AbstractProject类方法