当前位置: 首页>>代码示例>>Java>>正文


Java Queue.Item方法代码示例

本文整理汇总了Java中hudson.model.Queue.Item方法的典型用法代码示例。如果您正苦于以下问题:Java Queue.Item方法的具体用法?Java Queue.Item怎么用?Java Queue.Item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hudson.model.Queue的用法示例。


在下文中一共展示了Queue.Item方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cancelQueuedBuild

import hudson.model.Queue; //导入方法依赖的package包/类
@SuppressFBWarnings("SE_BAD_FIELD")
public static boolean cancelQueuedBuild(WorkflowJob job, Build build) {
	String buildUid = build.getMetadata().getUid();
	final Queue buildQueue = Jenkins.getActiveInstance().getQueue();
	for (final Queue.Item item : buildQueue.getItems()) {
		for (Cause cause : item.getCauses()) {
			if (cause instanceof BuildCause && ((BuildCause) cause).getUid().equals(buildUid)) {
				return ACL.impersonate(ACL.SYSTEM, new NotReallyRoleSensitiveCallable<Boolean, RuntimeException>() {
					@Override
					public Boolean call() throws RuntimeException {
						buildQueue.cancel(item);
						return true;
					}
				});
			}
		}
	}
	return cancelNotYetStartedBuild(job, build);
}
 
开发者ID:jenkinsci,项目名称:openshift-sync-plugin,代码行数:20,代码来源:JenkinsUtils.java

示例2: schedule

import hudson.model.Queue; //导入方法依赖的package包/类
boolean schedule(Cause cause) {
    if (!asJob().isBuildable()) {
        return false;
    }
    List<Action> queueActions = new LinkedList<Action>();

    queueActions.add(new ParametersAction(getParameterValues()));
    queueActions.add(new CauseAction(cause));

    int quiet = Math.max(MIN_QUIET, asJob().getQuietPeriod());

    final Jenkins jenkins = Jenkins.getInstance();
    if (jenkins == null) {
        logger.log(Level.WARNING, "Tried to schedule a build while Jenkins was gone.");
        return false;
    }
    final Queue queue = jenkins.getQueue();
    if (queue == null) {
        throw new IllegalStateException("The queue is not initialized?!");
    }
    Queue.Item i = queue.schedule2(asJob(), quiet, queueActions).getItem();
    return i != null && i.getFuture() != null;
}
 
开发者ID:jenkinsci,项目名称:dockerhub-notification-plugin,代码行数:24,代码来源:JSONWebHook.java

示例3: isUnblocked

import hudson.model.Queue; //导入方法依赖的package包/类
@Override
public boolean isUnblocked(Queue.Item item) {
    final List<Cause> causes = item.getCauses();
    for (Cause cause : causes) {
        if (cause instanceof GitHubPRCause) {
            final GitHubPRCause gitHubPRCause = (GitHubPRCause) cause;
            final Set<String> causeLabels = gitHubPRCause.getLabels();
            if (getLabel() != null) {
                if (causeLabels.containsAll(label.getLabelsSet())) {
                    if (item.task instanceof Job<?, ?>) {
                        final Job<?, ?> job = (Job<?, ?>) item.task;
                        LOGGER.debug("Unblocking job item {} with matched labels {}",
                                job.getFullName(), label.getLabelsSet());
                    }

                    return true;
                }
            }
        }
    }

    return false;
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:24,代码来源:GitHubPRLabelUnblockQueueCondition.java

示例4: cancelQueuedBuildByBranchName

import hudson.model.Queue; //导入方法依赖的package包/类
/**
 * Cancel previous builds for specified PR id.
 */
private static boolean cancelQueuedBuildByBranchName(final String branch) {
    Queue queue = getJenkinsInstance().getQueue();

    for (Queue.Item item : queue.getApproximateItemsQuickly()) {
        Optional<Cause> cause = from(item.getAllActions())
                .filter(instanceOf(CauseAction.class))
                .transformAndConcat(new CausesFromAction())
                .filter(instanceOf(GitHubBranchCause.class))
                .firstMatch(new CauseHasBranch(branch));

        if (cause.isPresent()) {
            queue.cancel(item);
            return true;
        }
    }

    return false;
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:22,代码来源:JobRunnerForBranchCause.java

示例5: cancelQueuedBuilds

import hudson.model.Queue; //导入方法依赖的package包/类
public static void cancelQueuedBuilds(WorkflowJob job, String bcUid) {
	Queue buildQueue = Jenkins.getActiveInstance().getQueue();
	for (Queue.Item item : buildQueue.getItems()) {
		for (Cause cause : item.getCauses()) {
			if (cause instanceof BuildCause) {
				BuildCause buildCause = (BuildCause) cause;
				if (buildCause.getBuildConfigUid().equals(bcUid)) {
					Build build = new BuildBuilder().withNewMetadata().withNamespace(buildCause.getNamespace())
							.withName(buildCause.getName()).and().build();
					cancelQueuedBuild(job, build);
				}
			}
		}
	}
}
 
开发者ID:jenkinsci,项目名称:openshift-sync-plugin,代码行数:16,代码来源:JenkinsUtils.java

示例6: createJenkinsModel

import hudson.model.Queue; //导入方法依赖的package包/类
public static JenkinsModel createJenkinsModel(Jenkins jenkins) {
  Queue queue = jenkins.getQueue();
  final Queue.Item[] items = queue.getItems();
  int queueLength = items.length;
  long maxwait = 0, averagewait = 0, now = System.currentTimeMillis();
  for(Queue.Item item : items){
    long waiting = now - item.getInQueueSince();
    maxwait = maxwait > waiting ? maxwait : waiting;
    averagewait += waiting;
  }
  if (queueLength > 0 ) {
    averagewait = averagewait / queueLength;
  }

  QueueModel queueModel = new QueueModel(queueLength,queueLength - queue.countBuildableItems(), maxwait, averagewait);

  int numFreeExecutors=0;

  for (Computer computer : jenkins.getComputers()) {
    if (computer.isOnline()){
      numFreeExecutors += computer.countIdle();
    }

  }
  SlaveModel slaveModel = new SlaveModel(jenkins.getComputers().length - 1, jenkins.getNumExecutors(), numFreeExecutors);

  return new JenkinsModel(queueModel, slaveModel, jenkins.getDescription());
}
 
开发者ID:SumoLogic,项目名称:sumologic-jenkins-plugin,代码行数:29,代码来源:ModelFactory.java

示例7: cancelPreviousJobsInQueueThatMatch

import hudson.model.Queue; //导入方法依赖的package包/类
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);
        }
    }
}
 
开发者ID:nishio-dens,项目名称:bitbucket-pullrequest-builder-plugin,代码行数:12,代码来源:BitbucketBuildTrigger.java

示例8: check

import hudson.model.Queue; //导入方法依赖的package包/类
@Override
public synchronized long check(final DeployNowComputer c) {
    if (!c.isIdle()) {
        return 1;
    }
    final Jenkins jenkins = Jenkins.getInstance();
    if (jenkins != null) {
        for (Queue.Item t : jenkins.getQueue().getItems()) {
            if (t.task instanceof DeployNowTask) {
                return 1;
            }
        }
    }
    if (!c.offline) {
        c.offline = true;
        try {
            if (jenkins != null) {
                Slave node = c.getNode();
                if (node != null) {
                    jenkins.removeNode(node);
                }
            }
        } catch (IOException e) {
            // ignore
        }
    }
    return 1;
}
 
开发者ID:jenkinsci,项目名称:deployer-framework-plugin,代码行数:29,代码来源:DeployNowComputer.java

示例9: isLogUpdated

import hudson.model.Queue; //导入方法依赖的package包/类
/**
 * Returns true if the log file is still being updated.
 */
public boolean isLogUpdated() {
    if (deployer != null) {
        return true;
    }
    for (Queue.Item item : Hudson.getInstance().getQueue().getItems()) {
        if (item.task instanceof DeployNowTask && owner.equals(DeployNowTask.class.cast(item.task).getBuild())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:jenkinsci,项目名称:deployer-framework-plugin,代码行数:15,代码来源:DeployNowRunAction.java

示例10: getQueuedBuilds

import hudson.model.Queue; //导入方法依赖的package包/类
private Iterable<QueuedBuild> getQueuedBuilds() {
    int nextBuildNumber = this.dynamicProject.getNextBuildNumber();
    final List<QueuedBuild> queuedBuilds = new ArrayList<>();
    for (final Queue.Item item : getQueuedItems()) {
        queuedBuilds.add(new QueuedBuild(item, nextBuildNumber++));
    }
    Collections.reverse(queuedBuilds);
    return queuedBuilds;
}
 
开发者ID:groupon,项目名称:DotCi,代码行数:10,代码来源:BuildHistory.java

示例11: getQueuedItems

import hudson.model.Queue; //导入方法依赖的package包/类
public List<Queue.Item> getQueuedItems() {
    final LinkedList<Queue.Item> list = new LinkedList<>();
    for (final Queue.Item item : Jenkins.getInstance().getQueue().getApproximateItemsQuickly()) {
        if (item.task == this.dynamicProject) {
            list.addFirst(item);
        }
    }
    return list;
}
 
开发者ID:groupon,项目名称:DotCi,代码行数:10,代码来源:BuildHistory.java

示例12: getTooltip

import hudson.model.Queue; //导入方法依赖的package包/类
public String getTooltip() {
    final Build r = getRun();
    if (r != null) {
        return r.getIconColor().getDescription();
    }
    final Queue.Item item = Jenkins.getInstance().getQueue().getItem(this.dynamicBuild.getParent().getItem(this.combination));
    if (item != null) {
        return item.getWhy();
    }
    return null; // fall back
}
 
开发者ID:groupon,项目名称:DotCi,代码行数:12,代码来源:DynamicRunPtr.java

示例13: waitForCompletion

import hudson.model.Queue; //导入方法依赖的package包/类
public CurrentBuildState waitForCompletion(final DynamicSubProject c, final TaskListener listener) throws InterruptedException {

        // wait for the completion
        int appearsCancelledCount = 0;
        while (true) {
            Thread.sleep(1000);
            final CurrentBuildState b = c.getCurrentStateByNumber(this.dynamicBuild.getNumber());
            if (b != null) { // its building or is done
                if (b.isBuilding()) {
                    continue;
                } else {
                    final Result buildResult = b.getResult();
                    if (buildResult != null) {
                        return b;
                    }
                }
            } else { // not building or done, check queue
                final Queue.Item qi = c.getQueueItem();
                if (qi == null) {
                    appearsCancelledCount++;
                    listener.getLogger().println(c.getName() + " appears cancelled: " + appearsCancelledCount);
                } else {
                    appearsCancelledCount = 0;
                }

                if (appearsCancelledCount >= 5) {
                    listener.getLogger().println(Messages.MatrixBuild_AppearsCancelled(ModelHyperlinkNote.encodeTo(c)));
                    return new CurrentBuildState("COMPLETED", Result.ABORTED);
                }
            }

        }
    }
 
开发者ID:groupon,项目名称:DotCi,代码行数:34,代码来源:SubBuildScheduler.java

示例14: canRun

import hudson.model.Queue; //导入方法依赖的package包/类
@Override
public CauseOfBlockage canRun(Queue.Item item) {
	initPython();
	if (pexec.isImplemented(2)) {
		return (CauseOfBlockage) pexec.execPython("can_run", item);
	} else {
		return super.canRun(item);
	}
}
 
开发者ID:conyx,项目名称:jenkins.py,代码行数:10,代码来源:QueueTaskDispatcherPW.java

示例15: testParameter

import hudson.model.Queue; //导入方法依赖的package包/类
/**
 * Verify RunSelectorParameter works via HTML form, http POST and CLI.
 */
@Test
public void testParameter() throws Exception {
    FreeStyleProject job = rule.createFreeStyleProject();
    job.addProperty(new ParametersDefinitionProperty(
            new RunSelectorParameter("SELECTOR", new StatusRunSelector(StatusRunSelector.BuildStatus.SUCCESSFUL), "foo")));
    CaptureEnvironmentBuilder ceb = new CaptureEnvironmentBuilder();
    job.getBuildersList().add(ceb);

    // Run via UI (HTML form)
    WebClient wc = rule.createWebClient();
    WebClientOptions wco = wc.getOptions();
    // Jenkins sends 405 response for GET of build page.. deal with that:
    wco.setThrowExceptionOnFailingStatusCode(false);
    wco.setPrintContentOnFailingStatusCode(false);
    HtmlForm form = wc.getPage(job, "build").getFormByName("parameters");
    form.getSelectByName("").getOptionByText("Specified by build number").setSelected(true);
    wc.waitForBackgroundJavaScript(10000);
    form.getInputByName("_.buildNumber").setValueAttribute("6");
    rule.submit(form);
    Queue.Item q = rule.jenkins.getQueue().getItem(job);
    if (q != null) q.getFuture().get();
    while (job.getLastBuild().isBuilding()) Thread.sleep(100);
    assertEquals("<BuildNumberRunSelector><buildNumber>6</buildNumber></BuildNumberRunSelector>",
            ceb.getEnvVars().get("SELECTOR").replaceAll("\\s+", ""));
    job.getBuildersList().replace(ceb = new CaptureEnvironmentBuilder());

    // Run via HTTP POST (buildWithParameters)
    WebRequest post = new WebRequest(
            new URL(rule.getURL(), job.getUrl() + "/buildWithParameters"), HttpMethod.POST);
    wc.addCrumb(post);
    String xml = "<StatusRunSelector><buildStatus>STABLE</buildStatus></StatusRunSelector>";
    post.setRequestParameters(Arrays.asList(new NameValuePair("SELECTOR", xml),
            post.getRequestParameters().get(0)));
    wc.getPage(post);
    q = rule.jenkins.getQueue().getItem(job);
    if (q != null) q.getFuture().get();
    while (job.getLastBuild().isBuilding()) Thread.sleep(100);
    assertEquals(xml, ceb.getEnvVars().get("SELECTOR"));
    job.getBuildersList().replace(ceb = new CaptureEnvironmentBuilder());

    // Run via CLI
    CLI cli = new CLI(rule.getURL());
    assertEquals(0, cli.execute(
            "build", job.getFullName(), "-p", "SELECTOR=<StatusRunSelector/>"));
    q = rule.jenkins.getQueue().getItem(job);
    if (q != null) q.getFuture().get();
    while (job.getLastBuild().isBuilding()) Thread.sleep(100);
    assertEquals("<StatusRunSelector/>", ceb.getEnvVars().get("SELECTOR"));
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:53,代码来源:RunSelectorParameterTest.java


注:本文中的hudson.model.Queue.Item方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。