/** * Like {@link #getItems()}, but returns an approximation that might not be completely up-to-date. * * <p> * At the expense of accuracy, this method does not usually lock {@link Queue} and therefore is faster * in a highly concurrent situation. * * <p> * The list obtained is an accurate snapshot of the queue at some point in the past. The snapshot * is updated and normally no more than one second old, but this is a soft commitment that might * get violated when the lock on {@link Queue} is highly contended. * * <p> * This method is primarily added to make UI threads run faster. * * @since 1.483 * @deprecated Use {@link #getItems()} directly. As of 1.607 the approximation is no longer needed. */ @Deprecated public List<Item> getApproximateItemsQuickly() { return Arrays.asList(getItems()); }
/** * Returns the queue item if the owner is scheduled for execution in the queue, in REVERSE ORDER */ public List<Item> getQueuedItems() { LinkedList<Item> list = new LinkedList<Item>(); for (Item item : Jenkins.getInstance().getQueue().getItems()) { if (item.task == owner) { list.addFirst(item); } } return list; }
public List<Queue.Item> getQueueItems() { return filterQueue(Arrays.asList(Jenkins.getInstance().getQueue().getItems())); }
/** * Persists the queue contents to the disk. */ public void save() { if(BulkChange.contains(this)) return; if (Jenkins.getInstanceOrNull() == null) { return; } XmlFile queueFile = new XmlFile(XSTREAM, getXMLQueueFile()); lock.lock(); try { // write out the queue state we want to save State state = new State(); state.counter = WaitingItem.COUNTER.longValue(); // write out the tasks on the queue for (Item item: getItems()) { if(item.task instanceof TransientTask) continue; state.items.add(item); } try { queueFile.write(state); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to write out the queue file " + getXMLQueueFile(), e); } } finally { lock.unlock(); } SaveableListener.fireOnChange(this, queueFile); }
public void cancelPendingBuilds(Job<?, ?> job, Integer projectId, String branch) { Queue queue = Jenkins.getInstance().getQueue(); for (Queue.Item item : queue.getItems()) { if (!job.getName().equals(item.task.getName())) { continue; } GitLabWebHookCause queueItemGitLabWebHookCause = getGitLabWebHookCauseData(item); if (queueItemGitLabWebHookCause == null) { continue; } CauseData queueItemCauseData = queueItemGitLabWebHookCause.getData(); if (!projectId.equals(queueItemCauseData.getSourceProjectId())) { continue; } if (branch.equals(queueItemCauseData.getBranch())) { cancel(item, queue, branch); setCommitStatusCancelledIfNecessary(queueItemCauseData, job); } } }
for (Queue.Item i : queue.getItems()) { Item item = Tasks.getItemOf(i.task); while (item != null) {
/** * Returns the queue item if the owner is scheduled for execution in the queue, in REVERSE ORDER */ public List<Item> getQueuedItems() { LinkedList<Item> list = new LinkedList<Item>(); for (Item item : Jenkins.getInstance().getQueue().getItems()) { if (item.task == owner) { list.addFirst(item); } } return list; }
/** * Returns the queue item if the owner is scheduled for execution in the queue, in REVERSE ORDER */ public List<Item> getQueuedItems() { List<Item> list = new ArrayList<Item>(Hudson.getInstance().getQueue().getItems(owner)); Collections.reverse(list); return list; } }
/** * Returns the queue item if the owner is scheduled for execution in the * queue, in REVERSE ORDER */ public List<Item> getQueuedItems() { List<Item> list = new ArrayList<Item>(Hudson.getInstance().getQueue().getItems(owner)); Collections.reverse(list); return list; } }
/** * Returns the queue item if the owner is scheduled for execution in the queue, in REVERSE ORDER */ public List<Item> getQueuedItems() { List<Item> list = new ArrayList<Item>(Hudson.getInstance().getQueue().getItems(owner)); Collections.reverse(list); return list; } }
/** * Returns the queue item if the owner is scheduled for execution in the queue, in REVERSE ORDER */ public List<Item> getQueuedItems() { List<Item> list = new ArrayList<Item>(Hudson.getInstance().getQueue().getItems(owner)); Collections.reverse(list); return list; } }
/** * Returns the {@link IvyModule}s that are in the queue. */ public List<Queue.Item> getQueueItems() { List<Queue.Item> r = new ArrayList<hudson.model.Queue.Item>(); for( Queue.Item item : Hudson.getInstance().getQueue().getItems() ) { Task t = item.task; if((t instanceof IvyModule && ((IvyModule)t).getParent()==this) || t ==this) r.add(item); } return r; }
private boolean buildsInQueue(hudson.model.Queue queue) { hudson.model.Queue.Item[] items = queue.getItems(); if(items != null) { for(hudson.model.Queue.Item item: items) { // Check and return if there is an item in jenkins queue for which this MesosCloud can provsion a slave if(mesosCloud.canProvision(item.getAssignedLabel())) { return true; } } } return false; }
/** * Returns the {@link IvyModule}s that are in the queue. */ public List<Queue.Item> getQueueItems() { List<Queue.Item> r = new ArrayList<hudson.model.Queue.Item>(); for( Queue.Item item : Hudson.getInstance().getQueue().getItems() ) { Task t = item.task; if((t instanceof IvyModule && ((IvyModule)t).getParent()==this) || t ==this) r.add(item); } return r; }
/** * Returns the {@link MavenModule}s that are in the queue. */ public List<Queue.Item> getQueueItems() { List<Queue.Item> r = new ArrayList<hudson.model.Queue.Item>(); for( Queue.Item item : Hudson.getInstance().getQueue().getItems() ) { Task t = item.task; if((t instanceof MavenModule && ((MavenModule)t).getParent()==this) || t ==this) r.add(item); } return r; }
public List<Queue.Item> getQueueItems() { if (!isFilterQueue()) { return Arrays.asList(Hudson.getInstance().getQueue().getItems()); } Collection<TopLevelItem> items = getItems(); List<Queue.Item> result = new ArrayList<Queue.Item>(); for (Queue.Item qi : Hudson.getInstance().getQueue().getItems()) { if (items.contains(qi.task)) { result.add(qi); } } return result; }
@Override public synchronized Item getQueueItem() { final Queue queue = Jenkins.getInstance().getQueue(); final Item[] items = queue.getItems(); for (int i = 0; i < items.length; i++) { if (items[i].task != null && items[i].task.equals(this)) { return items[i]; } } return super.getQueueItem(); }
private void cancelPreviousJobsInQueueThatMatch(@Nonnull StashCause stashCause) { logger.fine("Looking for queued jobs that match PR ID: " + stashCause.getPullRequestId()); Queue queue = Jenkins.getInstance().getQueue(); for (Queue.Item item : queue.getItems()) { if (hasCauseFromTheSamePullRequest(item.getCauses(), stashCause)) { logger.info("Canceling item in queue: " + item); queue.cancel(item); } } }
private void cancelPreviousJobsInQueueThatMatch(@Nonnull BitbucketCause bitbucketCause) { logger.fine("Looking for queued jobs that match PR ID: " + bitbucketCause.getPullRequestId()); Queue queue = getInstance().getQueue(); for (Queue.Item item : queue.getItems()) { if (hasCauseFromTheSamePullRequest(item.getCauses(), bitbucketCause)) { logger.fine("Canceling item in queue: " + item); queue.cancel(item); } } }
public boolean isInQueue(@Nonnull AbstractBuild<?,?> build) { for (Item item : JenkinsHelper.getInstance().getQueue().getItems(this)) if (item.getAction(PromotionTargetAction.class).resolve(this)==build) return true; return false; }