private boolean fitsSearchParams(@Nonnull Run run) { if (searchString == null) { return true; } if (fitsSearchString(run.getDisplayName())) { return true; } else if (fitsSearchString(run.getDescription())) { return true; } else if (fitsSearchString(run.getNumber())) { return true; } else if (fitsSearchString(run.getQueueId())) { return true; } else if (fitsSearchString(run.getResult())) { return true; } else if (run instanceof AbstractBuild && fitsSearchBuildVariables((AbstractBuild) run)) { return true; } else { ParametersAction parametersAction = run.getAction(ParametersAction.class); if (parametersAction != null && fitsSearchBuildParameters(parametersAction)) { return true; } } // Non of the fuzzy matches "liked" the search term. return false; }
/** * Gets the queue ids of all upstream projects that triggered argument queue item. * @param item the queue item to find upstream projects for * @return set of upstream project names */ public static Set<Long> getUpstreamQueueIds(Queue.Item item) { Set<Long> upstreamProjects = new HashSet<Long>(); for (Cause cause : item.getCauses()) { if (cause instanceof Cause.UpstreamCause) { Cause.UpstreamCause upstreamCause = (Cause.UpstreamCause)cause; Run<?, ?> run = upstreamCause.getUpstreamRun(); upstreamCause.getUpstreamProject(); if (run != null) { upstreamProjects.add(run.getQueueId()); } } } return Collections.unmodifiableSet(upstreamProjects); }
@Override public void onStarted(Run<?, ?> run, TaskListener listener) { for (BuildTriggerAction.Trigger trigger : BuildTriggerAction.triggersFor(run)) { StepContext stepContext = trigger.context; if (stepContext != null && stepContext.isReady()) { LOGGER.log(Level.FINE, "started building {0} from #{1} in {2}", new Object[] {run, run.getQueueId(), stepContext}); try { TaskListener taskListener = stepContext.get(TaskListener.class); // encodeTo(Run) calls getDisplayName, which does not include the project name. taskListener.getLogger().println("Starting building: " + ModelHyperlinkNote.encodeTo("/" + run.getUrl(), run.getFullDisplayName())); } catch (Exception e) { LOGGER.log(WARNING, null, e); } } else { LOGGER.log(Level.FINE, "{0} unavailable in {1}", new Object[] {stepContext, run}); } } }
Queue.Item item = queue.getItem(run.getQueueId());
/** * Create a message instance associated with a Jenkins {@link Run}. * @param run The Jenkins {@link Run} with this message instance is to be associated. */ public RunMessage(@Nonnull Run run) { super(run.getParent()); this.run = run; set(EventProps.Jenkins.jenkins_object_name, run.getDisplayName()); set(EventProps.Jenkins.jenkins_object_id, run.getId()); set(EventProps.Jenkins.jenkins_object_url, run.getUrl()); set(EventProps.Job.job_run_queueId, Long.toString(run.getQueueId())); Result result = run.getResult(); if (result != null) { set(EventProps.Job.job_run_status, result.toString()); } else { set(EventProps.Job.job_run_status, "RUNNING"); } }
private void cancelPreviousPullRequestBuilds(Job job, TeamPullRequestMergedDetailsAction pullReqeuestMergedDetails, Queue queue) { RunList<?> allBuilds = job.getBuilds(); for (Run run : allBuilds) { TeamPullRequestMergedDetailsAction cause = run.getAction(TeamPullRequestMergedDetailsAction.class); if (cause != null && run.isBuilding()) { if (cause instanceof TeamPullRequestMergedDetailsAction && cause.gitPullRequest.getPullRequestId() == pullReqeuestMergedDetails.gitPullRequest.getPullRequestId()) { LOGGER.info("Canceling previously triggered Job: " + run.getFullDisplayName()); Executor executor = run.getExecutor(); if (executor != null) executor.doStop(); Queue.Item item = queue.getItem(run.getQueueId()); if (item != null) queue.cancel(item); } } } }
shutdownManageLink.removeActiveQueueId(r.getQueueId());
private boolean fitsSearchParams(@Nonnull Run run) { if (searchString == null) { return true; } if (fitsSearchString(run.getDisplayName())) { return true; } else if (fitsSearchString(run.getDescription())) { return true; } else if (fitsSearchString(run.getNumber())) { return true; } else if (fitsSearchString(run.getQueueId())) { return true; } else if (fitsSearchString(run.getResult())) { return true; } else if (run instanceof AbstractBuild && fitsSearchBuildVariables((AbstractBuild) run)) { return true; } else { ParametersAction parametersAction = run.getAction(ParametersAction.class); if (parametersAction != null && fitsSearchBuildParameters(parametersAction)) { return true; } } // Non of the fuzzy matches "liked" the search term. return false; }
build.put("queue_id", r.getQueueId()); build.put("phase", phase); build.put("url", r.getUrl());