本文整理汇总了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);
}
}
示例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);
}
示例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
);
}
示例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);
}
示例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;
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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();
}
}
}
}
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}