Java Code Examples for hudson.model.Label#matches()
The following examples show how to use
hudson.model.Label#matches() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractCloud.java From yet-another-docker-plugin with MIT License | 6 votes |
/** * Multiple templates may have the same label. * * @return Templates matched to requested label assuming slave Mode */ @Nonnull public List<DockerSlaveTemplate> getTemplates(Label label) { List<DockerSlaveTemplate> dockerSlaveTemplates = new ArrayList<>(); for (DockerSlaveTemplate t : templates) { if (isNull(label) && t.getMode() == Node.Mode.NORMAL) { dockerSlaveTemplates.add(t); } if (nonNull(label) && label.matches(t.getLabelSet())) { dockerSlaveTemplates.add(t); } } return dockerSlaveTemplates; }
Example 2
Source File: DockerCloud.java From docker-plugin with MIT License | 6 votes |
/** * Multiple amis can have the same label. * * @return Templates matched to requested label assuming slave Mode */ public List<DockerTemplate> getTemplates(Label label) { final List<DockerTemplate> dockerTemplates = new ArrayList<>(); for (DockerTemplate t : getTemplates()) { if ( t.getDisabled().isDisabled() ) { continue; // pretend it doesn't exist } if (label == null && t.getMode() == Node.Mode.NORMAL) { dockerTemplates.add(t); } if (label != null && label.matches(t.getLabelSet())) { dockerTemplates.add(t); } } // add temporary templates matched to requested label for (DockerTemplate template : getJobTemplates().values()) { if (label != null && label.matches(template.getLabelSet())) { dockerTemplates.add(template); } } return dockerTemplates; }
Example 3
Source File: NomadCloud.java From jenkins-nomad with MIT License | 5 votes |
public NomadSlaveTemplate getTemplate(Label label) { for (NomadSlaveTemplate t : templates) { if (label == null && !t.getLabelSet().isEmpty()) { continue; } if ((label == null && t.getLabelSet().isEmpty()) || (label != null && label.matches(t.getLabelSet()))) { return t; } } return null; }
Example 4
Source File: ParallelsDesktopCloud.java From jenkins-parallels with MIT License | 5 votes |
@Override public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) { LOGGER.log(Level.SEVERE, "Going to provision " + excessWorkload + " executors"); Collection<NodeProvisioner.PlannedNode> result = new ArrayList<NodeProvisioner.PlannedNode>(); final ParallelsDesktopConnectorSlaveComputer connector = getConnector(); for (int i = 0; (i < vms.size()) && (excessWorkload > 0); i++) { final ParallelsDesktopVM vm = vms.get(i); if (vm.isProvisioned()) continue; if (!label.matches(Label.parse(vm.getLabels()))) continue; final String vmId = vm.getVmid(); final String slaveName = name + " " + vmId; vm.setSlaveName(slaveName); vm.setProvisioned(true); --excessWorkload; result.add(new NodeProvisioner.PlannedNode(slaveName, Computer.threadPoolForRemoting.submit(new Callable<Node>() { @Override public Node call() throws Exception { connector.checkVmExists(vmId); return connector.createSlaveOnVM(vm); } }), 1)); } return result; }
Example 5
Source File: ParallelsDesktopCloud.java From jenkins-parallels with MIT License | 5 votes |
@Override public boolean canProvision(Label label) { if (label != null) { for (ParallelsDesktopVM vm : vms) { if (label.matches(Label.parse(vm.getLabels()))) return true; } } return false; }
Example 6
Source File: PodTemplateUtils.java From kubernetes-plugin with Apache License 2.0 | 5 votes |
/** * Gets the {@link PodTemplate} by {@link Label}. * @param label The label. * @param templates The list of all templates. * @return The first pod template from the collection that has a matching label. */ public static PodTemplate getTemplateByLabel(@CheckForNull Label label, Collection<PodTemplate> templates) { for (PodTemplate t : templates) { if ((label == null && t.getNodeUsageMode() == Node.Mode.NORMAL) || (label != null && label.matches(t.getLabelSet()))) { return t; } } return null; }
Example 7
Source File: PodTemplateLabelFilter.java From kubernetes-plugin with Apache License 2.0 | 5 votes |
@Override protected PodTemplate transform(@Nonnull KubernetesCloud cloud, @Nonnull PodTemplate podTemplate, @CheckForNull Label label) { if ((label == null && podTemplate.getNodeUsageMode() == Node.Mode.NORMAL) || (label != null && label.matches(podTemplate.getLabelSet()))) { return podTemplate; } return null; }
Example 8
Source File: ECSCloud.java From amazon-ecs-plugin with MIT License | 5 votes |
private ECSTaskTemplate getTemplate(Label label) { if (label == null) { return null; } for (ECSTaskTemplate t : getAllTemplates()) { if (label.matches(t.getLabelSet())) { return t; } } return null; }
Example 9
Source File: KafkaKubernetesCloud.java From remoting-kafka-plugin with MIT License | 4 votes |
@Override public boolean canProvision(@CheckForNull Label label) { if (label == null) return false; return label.matches(getLabelSet()); }