jenkins.model.Jenkins.getLabels()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(224)

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

Jenkins.getLabels介绍

[英]Gets all the active labels in the current system.
[中]获取当前系统中的所有活动标签。

代码示例

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

@Override
  protected void doRun() {
    Jenkins j = Jenkins.get();
    j.unlabeledNodeProvisioner.update();
    for( Label l : j.getLabels() )
      l.nodeProvisioner.update();
  }
}

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

public AutoCompletionCandidates doAutoCompleteLabel(@QueryParameter String value) {
  AutoCompletionCandidates c = new AutoCompletionCandidates();
  Set<Label> labels = Jenkins.getInstance().getLabels();
  List<String> queries = new AutoCompleteSeeder(value).getSeeds();
  for (String term : queries) {
    for (Label l : labels) {
      if (l.getName().startsWith(term)) {
        c.add(l.getName());
      }
    }
  }
  return c;
}

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

protected void doRun() {
  Jenkins j = Jenkins.getInstance();
  List<Queue.BuildableItem> bis = j.getQueue().getBuildableItems();
  // update statistics on agents
  for( Label l : j.getLabels() ) {
    l.loadStatistics.updateCounts(l.loadStatistics.computeSnapshot(bis));
  }
  // update statistics of the entire system
  j.unlabeledLoad.updateCounts(j.unlabeledLoad.computeSnapshot(bis));
  j.overallLoad.updateCounts(j.overallLoad.computeSnapshot(bis));
}

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

@Override
  protected void doRun() {
    Jenkins h = Jenkins.getInstance();
    h.unlabeledNodeProvisioner.update();
    for( Label l : h.getLabels() )
      l.nodeProvisioner.update();
  }
}

代码示例来源:origin: org.jenkins-ci.plugins.workflow/workflow-durable-task-step

public AutoCompletionCandidates doAutoCompleteLabel(@QueryParameter String value) {
  AutoCompletionCandidates c = new AutoCompletionCandidates();
  Jenkins j = Jenkins.getInstance();
  if (j != null) {
    for (Label label : j.getLabels()) {
      if (label.getName().startsWith(value)) {
        c.add(label.getName());
      }
    }
  }
  return c;
}

代码示例来源:origin: jenkinsci/pipeline-utility-steps-plugin

@SuppressWarnings("unused") // used by stapler
public ComboBoxModel doFillLabelItems() {
  ComboBoxModel cbm = new ComboBoxModel();
  Set<Label> labels = Jenkins.getInstance().getLabels();
  for (Label label : labels) {
    cbm.add(label.getDisplayName());
  }
  return cbm;
}

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

public AutoCompletionCandidates doAutoCompleteLabel(@QueryParameter String value) {
  AutoCompletionCandidates c = new AutoCompletionCandidates();
  Set<Label> labels = Jenkins.getInstance().getLabels();
  List<String> queries = new AutoCompleteSeeder(value).getSeeds();
  for (String term : queries) {
    for (Label l : labels) {
      if (l.getName().startsWith(term)) {
        c.add(l.getName());
      }
    }
  }
  return c;
}

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

public AutoCompletionCandidates doAutoCompleteAssignedLabelString(@QueryParameter String value) {
  AutoCompletionCandidates c = new AutoCompletionCandidates();
  Set<Label> labels = JenkinsHelper.getInstance().getLabels();
  List<String> queries = new AutoCompleteSeeder(value).getSeeds();
  for (String term : queries) {
    for (Label l : labels) {
      if (l.getName().startsWith(term)) {
        c.add(l.getName());
      }
    }
  }
  return c;
}

代码示例来源:origin: org.jenkins-ci.plugins/nodelabelparameter

/**
 * Called by UI - Autocompletion for label values
 *
 * @param value the current value in the text field to base the automcompetion upon.
 * @return
 */
public AutoCompletionCandidates doAutoCompleteDefaultValue(@QueryParameter String value) {
  final AutoCompletionCandidates candidates = new AutoCompletionCandidates();
  for (Label l : Jenkins.getInstance().getLabels()) {
    String label = l.getExpression();
    if (StringUtils.containsIgnoreCase(label, value)) {
      candidates.add(label);
    }
  }
  return candidates;
}

代码示例来源:origin: jenkinsci/azure-vm-agents-plugin

public void cleanCloudStatistics() {
  Jenkins jenkins = Jenkins.getInstance();
  Set<ProvisioningActivity.Id> plannedNodesSet = new HashSet<>();
  for (NodeProvisioner.PlannedNode node : jenkins.unlabeledNodeProvisioner.getPendingLaunches()) {
    if (node instanceof TrackedItem) {
      plannedNodesSet.add(((TrackedItem) node).getId());
    }
  }
  for (Label l : jenkins.getLabels()) {
    for (NodeProvisioner.PlannedNode node : l.nodeProvisioner.getPendingLaunches()) {
      if (node instanceof TrackedItem) {
        plannedNodesSet.add(((TrackedItem) node).getId());
      }
    }
  }
  for (Node node : jenkins.getNodes()) {
    if (node instanceof TrackedItem) {
      plannedNodesSet.add(((TrackedItem) node).getId());
    }
  }
  Collection<ProvisioningActivity> activities = CloudStatistics.get().getNotCompletedActivities();
  for (ProvisioningActivity activity : activities) {
    if (activity.getCurrentPhase().equals(ProvisioningActivity.Phase.PROVISIONING)
        && !plannedNodesSet.contains(activity.getId())) {
      Exception e = new Exception(String.format("Node %s has lost. Mark as failure",
          activity.getId().toString()));
      CloudStatistics.ProvisioningListener.get().onFailure(activity.getId(), e);
    }
  }
}

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

protected void doRun() {
  Jenkins j = Jenkins.getInstance();
  List<Queue.BuildableItem> bis = j.getQueue().getBuildableItems();
  // update statistics on agents
  for( Label l : j.getLabels() ) {
    l.loadStatistics.updateCounts(l.loadStatistics.computeSnapshot(bis));
  }
  // update statistics of the entire system
  j.unlabeledLoad.updateCounts(j.unlabeledLoad.computeSnapshot(bis));
  j.overallLoad.updateCounts(j.overallLoad.computeSnapshot(bis));
}

相关文章

Jenkins类方法