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


Java Queue类代码示例

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


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

示例1: doEndOfflineAgentJobs

import hudson.model.Queue; //导入依赖的package包/类
public void doEndOfflineAgentJobs(final StaplerRequest request, final StaplerResponse response) {

		Jenkins j;
		if ((j = Jenkins.getInstance()) != null) {
			Queue queue = j.getQueue();
			if (queue != null) {
				for (Item job : queue.getItems()) {
					if (job.getCauseOfBlockage() instanceof BecauseNodeIsOffline
							|| job.getCauseOfBlockage() instanceof BecauseLabelIsOffline) {
						queue.cancel(job);
					}
				}
			}
		}

		try {
			response.sendRedirect2(request.getRootPath());
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
开发者ID:jenkinsci,项目名称:no-agent-job-purge-plugin,代码行数:22,代码来源:PurgeNoAgentJobs.java

示例2: doFillCredentialsIdItems

import hudson.model.Queue; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(
    @AncestorInPath Item context,
    @QueryParameter String remote,
    @QueryParameter String credentialsId) {
  if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)
      || context != null && !context.hasPermission(Item.EXTENDED_READ)) {
    return new StandardListBoxModel().includeCurrentValue(credentialsId);
  }
  return new StandardListBoxModel()
      .includeEmptyValue()
      .includeMatchingAs(
          context instanceof Queue.Task
              ? Tasks.getAuthenticationOf((Queue.Task) context)
              : ACL.SYSTEM,
          context,
          StandardUsernameCredentials.class,
          URIRequirementBuilder.fromUri(remote).build(),
          GitClient.CREDENTIALS_MATCHER)
      .includeCurrentValue(credentialsId);
}
 
开发者ID:GerritForge,项目名称:gerrit-plugin,代码行数:21,代码来源:GerritSCMSource.java

示例3: doFillCheckoutCredentialsIdItems

import hudson.model.Queue; //导入依赖的package包/类
@Restricted(NoExternalUse.class)
public ListBoxModel doFillCheckoutCredentialsIdItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String connectionName, @QueryParameter String checkoutCredentialsId) {
    if (context == null && !Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER) ||
            context != null && !context.hasPermission(Item.EXTENDED_READ)) {
        return new StandardListBoxModel().includeCurrentValue(checkoutCredentialsId);
    }

    StandardListBoxModel result = new StandardListBoxModel();
    result.add("- anonymous -", CHECKOUT_CREDENTIALS_ANONYMOUS);
    return result.includeMatchingAs(
            context instanceof Queue.Task
                    ? Tasks.getDefaultAuthenticationOf((Queue.Task) context)
                    : ACL.SYSTEM,
            context,
            StandardUsernameCredentials.class,
            SettingsUtils.gitLabConnectionRequirements(connectionName),
            GitClient.CREDENTIALS_MATCHER
    );
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:20,代码来源:GitLabSCMSourceSettings.java

示例4: 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

示例5: isUpstreamBuildVisibleByDownstreamBuildAuth

import hudson.model.Queue; //导入依赖的package包/类
protected boolean isUpstreamBuildVisibleByDownstreamBuildAuth(@Nonnull WorkflowJob upstreamPipeline, @Nonnull Queue.Task downstreamPipeline) {
    Authentication auth = Tasks.getAuthenticationOf(downstreamPipeline);
    Authentication downstreamPipelineAuth;
    if (auth.equals(ACL.SYSTEM) && !QueueItemAuthenticatorConfiguration.get().getAuthenticators().isEmpty()) {
        downstreamPipelineAuth = Jenkins.ANONYMOUS; // cf. BuildTrigger
    } else {
        downstreamPipelineAuth = auth;
    }

    try (ACLContext _ = ACL.as(downstreamPipelineAuth)) {
        WorkflowJob upstreamPipelineObtainedAsImpersonated = Jenkins.getInstance().getItemByFullName(upstreamPipeline.getFullName(), WorkflowJob.class);
        boolean result = upstreamPipelineObtainedAsImpersonated != null;
        LOGGER.log(Level.FINE, "isUpstreamBuildVisibleByDownstreamBuildAuth({0}, {1}): taskAuth: {2}, downstreamPipelineAuth: {3}, upstreamPipelineObtainedAsImpersonated:{4}, result: {5}",
                new Object[]{upstreamPipeline, downstreamPipeline, auth, downstreamPipelineAuth, upstreamPipelineObtainedAsImpersonated, result});
        return result;
    }
}
 
开发者ID:jenkinsci,项目名称:pipeline-maven-plugin,代码行数:18,代码来源:DownstreamPipelineTriggerRunListener.java

示例6: done

import hudson.model.Queue; //导入依赖的package包/类
protected void done(Executor executor) {
    final AbstractCloudComputer<?> c = (AbstractCloudComputer) executor.getOwner();
    Queue.Executable exec = executor.getCurrentExecutable();
    if (executor instanceof OneOffExecutor) {
        LOG.debug("Not terminating {} because {} was a flyweight task", c.getName(), exec);
        return;
    }

    if (exec instanceof ContinuableExecutable && ((ContinuableExecutable) exec).willContinue()) {
        LOG.debug("not terminating {} because {} says it will be continued", c.getName(), exec);
        return;
    }

    LOG.debug("terminating {} since {} seems to be finished", c.getName(), exec);
    done(c);
}
 
开发者ID:KostyaSha,项目名称:yet-another-docker-plugin,代码行数:17,代码来源:DockerOnceRetentionStrategy.java

示例7: 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

示例8: 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

示例9: 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

示例10: doFillCredentialItems

import hudson.model.Queue; //导入依赖的package包/类
@SuppressFBWarnings(value="NP_NULL_PARAM_DEREF", justification="pending https://github.com/jenkinsci/credentials-plugin/pull/68")
static public ListBoxModel doFillCredentialItems(Item project, String credentialsId) {

	if(project == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
			project != null && !project.hasPermission(Item.EXTENDED_READ)) {
		return new StandardListBoxModel().includeCurrentValue(credentialsId);
	}

	return new StandardListBoxModel()
			.includeEmptyValue()
			.includeMatchingAs(
					project instanceof Queue.Task
							? Tasks.getAuthenticationOf((Queue.Task) project)
							: ACL.SYSTEM,
					project,
					P4BaseCredentials.class,
					Collections.<DomainRequirement>emptyList(),
					CredentialsMatchers.instanceOf(P4BaseCredentials.class));
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:20,代码来源:P4CredentialsImpl.java

示例11: cancelSubBuilds

import hudson.model.Queue; //导入依赖的package包/类
public void cancelSubBuilds(final PrintStream logger) {
    final Queue q = getJenkins().getQueue();
    synchronized (q) {
        final int n = this.dynamicBuild.getNumber();
        for (final Item i : q.getItems()) {
            final ParentBuildAction parentBuildAction = i.getAction(ParentBuildAction.class);
            if (parentBuildAction != null && this.dynamicBuild.equals(parentBuildAction.getParent())) {
                q.cancel(i);
            }
        }
        for (final DynamicSubProject c : this.dynamicBuild.getAllSubProjects()) {
            final DynamicSubBuild b = c.getBuildByNumber(n);
            if (b != null && b.isBuilding()) {
                final Executor exe = b.getExecutor();
                if (exe != null) {
                    logger.println(Messages.MatrixBuild_Interrupting(ModelHyperlinkNote.encodeTo(b)));
                    exe.interrupt();
                }
            }
        }
    }
}
 
开发者ID:groupon,项目名称:DotCi,代码行数:23,代码来源:SubBuildScheduler.java

示例12: testDeclineOffersWithBuildsInQueue

import hudson.model.Queue; //导入依赖的package包/类
@Test
public void testDeclineOffersWithBuildsInQueue() throws Exception {
    Protos.Offer offer = createOfferWithVariableRanges(31000, 32000);
    ArrayList<Protos.Offer> offers = new ArrayList<Protos.Offer>();
    offers.add(offer);

    Queue queue = Mockito.mock(Queue.class);
    Mockito.when(jenkins.getQueue()).thenReturn(queue);

    Item item = Mockito.mock(Item.class);
    Item [] items = {item};
    Mockito.when(queue.getItems()).thenReturn(items);
    Mockito.when(mesosCloud.canProvision(null)).thenReturn(true);

    SchedulerDriver driver = Mockito.mock(SchedulerDriver.class);
    Mockito.when(mesosCloud.getDeclineOfferDurationDouble()).thenReturn((double) 120000);
    jenkinsScheduler.resourceOffers(driver, offers);
    Mockito.verify(driver).declineOffer(offer.getId());
    Mockito.verify(driver, Mockito.never()).declineOffer(offer.getId(), Protos.Filters.newBuilder().setRefuseSeconds(120000).build());
}
 
开发者ID:jenkinsci,项目名称:mesos-plugin,代码行数:21,代码来源:JenkinsSchedulerTest.java

示例13: canTake

import hudson.model.Queue; //导入依赖的package包/类
public CauseOfBlockage canTake(Node node,
                               Queue.BuildableItem item) {
    // Ask the AvailabilityMonitor for this node if it's okay to
    // run this build.
    ExecutorWorkerThread workerThread = null;

    synchronized(gewtHandles) {
        Computer computer = node.toComputer();
        for (ExecutorWorkerThread t : gewtHandles) {
            if (t.getComputer() == computer) {
                workerThread = t;
                break;
            }
        }
    }

    if (workerThread != null) {
        if (workerThread.getAvailability().canTake(item)) {
            return null;
        } else {
            return new CauseOfBlockage.BecauseNodeIsBusy(node);
        }
    }
    return null;
}
 
开发者ID:openstack-infra,项目名称:gearman-plugin,代码行数:26,代码来源:GearmanProxy.java

示例14: canTake

import hudson.model.Queue; //导入依赖的package包/类
public boolean canTake(Queue.BuildableItem item)
{
    // Jenkins calls this from within the scheduler maintenance
    // function (while owning the queue monitor).  If we are
    // locked, only allow the build we are expecting to run.
    logger.debug("AvailabilityMonitor canTake request for " +
                 workerHoldingLock);

    NodeParametersAction param = item.getAction(NodeParametersAction.class);
    if (param != null) {
        logger.debug("AvailabilityMonitor canTake request for UUID " +
                     param.getUuid() + " expecting " + expectedUUID);

        if (expectedUUID == param.getUuid()) {
            return true;
        }
    }
    return (workerHoldingLock == null);
}
 
开发者ID:openstack-infra,项目名称:gearman-plugin,代码行数:20,代码来源:NodeAvailabilityMonitor.java

示例15: doFillCredentialsIdItems

import hudson.model.Queue; //导入依赖的package包/类
/**
 * Populates the list of credentials in the select box in CodeScene API configuration section
 * Inspired by git plugin:
 * https://github.com/jenkinsci/git-plugin/blob/f58648e9005293ab07b2389212603ff9a460b80a/src/main/java/jenkins/plugins/git/GitSCMSource.java#L239
 */
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId) {
    if (context == null || !context.hasPermission(Item.CONFIGURE)) {
        return new StandardListBoxModel().includeCurrentValue(credentialsId);
    }
    return new StandardListBoxModel()
            .includeEmptyValue()
            .includeMatchingAs(
                    context instanceof Queue.Task ? Tasks.getAuthenticationOf((Queue.Task)context) : ACL.SYSTEM,
                    context,
                    StandardUsernameCredentials.class,
                    Collections.<DomainRequirement>emptyList(),
                    CredentialsMatchers.always())
            .includeCurrentValue(credentialsId);
}
 
开发者ID:empear-analytics,项目名称:codescene-jenkins-plugin,代码行数:20,代码来源:CodeSceneBuilder.java


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