Java Code Examples for hudson.model.Job#getLastCompletedBuild()
The following examples show how to use
hudson.model.Job#getLastCompletedBuild() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IssuesTablePortlet.java From warnings-ng-plugin with MIT License | 6 votes |
private void populateRows(final List<Job<?, ?>> visibleJobs, final SortedMap<String, String> toolNamesById) { for (Job<?, ?> job : visibleJobs) { TableRow row = new TableRow(job); for (String id : toolNamesById.keySet()) { Run<?, ?> lastCompletedBuild = job.getLastCompletedBuild(); if (lastCompletedBuild == null) { row.add(Result.EMPTY); } else { Result result = lastCompletedBuild.getActions(ResultAction.class) .stream() .filter(action -> action.getId().equals(id)) .findFirst() .map(Result::new) .orElse(Result.EMPTY); row.add(result); } } rows.add(row); } }
Example 2
Source File: IssuesTotalColumn.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Returns the total number of issues for the selected static analysis tool in a given job. * * @param job * the job to select * * @return the number of issues for a tool in a given job */ @SuppressWarnings("WeakerAccess") // called bv view public OptionalInt getTotal(final Job<?, ?> job) { Run<?, ?> lastCompletedBuild = job.getLastCompletedBuild(); if (lastCompletedBuild == null) { return OptionalInt.empty(); } return lastCompletedBuild.getActions(ResultAction.class).stream() .filter(createToolFilter(selectTools, tools)) .map(ResultAction::getResult) .map(AnalysisResult::getTotals) .mapToInt(totals -> type.getSizeGetter().apply(totals)) .reduce(Integer::sum); }
Example 3
Source File: IssuesTotalColumn.java From warnings-ng-plugin with MIT License | 5 votes |
/** * Returns the total number of issues for the selected static analysis tool in a given job. * * @param job * the job to select * * @return the number of issues for a tool in a given job */ @SuppressWarnings("WeakerAccess") // called bv view public List<AnalysisResultDescription> getDetails(final Job<?, ?> job) { Run<?, ?> lastCompletedBuild = job.getLastCompletedBuild(); if (lastCompletedBuild == null) { return Collections.emptyList(); } return lastCompletedBuild.getActions(ResultAction.class).stream() .filter(createToolFilter(selectTools, tools)) .map(result -> new AnalysisResultDescription(result, getLabelProviderFactory(), type)) .collect(Collectors.toList()); }
Example 4
Source File: IssuesTablePortlet.java From warnings-ng-plugin with MIT License | 5 votes |
private boolean isVisible(final Job<?, ?> job) { if (!hideCleanJobs) { return true; } Run<?, ?> lastCompletedBuild = job.getLastCompletedBuild(); if (lastCompletedBuild == null) { return true; } return lastCompletedBuild.getActions(ResultAction.class) .stream() .filter(createToolFilter(selectTools, tools)) .anyMatch(resultAction -> resultAction.getResult().getTotalSize() > 0); }
Example 5
Source File: ViewTracker.java From rocket-chat-notifier with Apache License 2.0 | 5 votes |
private Result getResult(View view) { Result ret = Result.SUCCESS; for (TopLevelItem item : view.getAllItems()) { for (Job<?,?> job : item.getAllJobs()) { Run<?, ?> build = job.getLastCompletedBuild(); if(build != null) { Result result = build.getResult(); if(result.isBetterOrEqualTo(Result.FAILURE)) ret = ret.combine(result); } } } return ret; }
Example 6
Source File: ImageAction.java From docker-workflow-plugin with MIT License | 5 votes |
@Override public Collection<String> getDockerImagesUsedByJob(Job<?,?> job) { Run<?,?> build = job.getLastCompletedBuild(); if (build != null) { ImageAction action = build.getAction(ImageAction.class); if (action != null) { Set<String> bareNames = new TreeSet<String>(); for (String name : action.names) { bareNames.add(name./* strip any tag or hash */replaceFirst("[:@].+", "")); } return bareNames; } } return Collections.emptySet(); }
Example 7
Source File: AWSDeviceFarmUtils.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 5 votes |
/** * Returns the most recent AWS Device Farm test result from the previous build. * * @param job The job which generated an AWS Device Farm test result * @return The previous Device Farm build result. */ public static AWSDeviceFarmTestResult previousAWSDeviceFarmBuildResult(Job job) { Run prev = job.getLastCompletedBuild(); if (prev == null) { return null; } AWSDeviceFarmTestResultAction action = prev.getAction(AWSDeviceFarmTestResultAction.class); if (action == null) { return null; } return action.getResult(); }
Example 8
Source File: ByStatus.java From jenkins-build-monitor-plugin with MIT License | 5 votes |
private int compareProjects(Job<?, ?> a, Job<?, ?> b) { Run<?, ?> recentBuildOfA = a.getLastCompletedBuild(); Run<?, ?> recentBuildOfB = b.getLastCompletedBuild(); if (recentBuildOfA == null && recentBuildOfB != null) { return -1; } else if (recentBuildOfA != null && recentBuildOfB == null) { return 1; } else { return 0; } }
Example 9
Source File: ByStatus.java From jenkins-build-monitor-plugin with MIT License | 4 votes |
private boolean bothProjectsHaveBuildHistory(Job<?, ?> a, Job<?, ?> b) { return a.getLastCompletedBuild() != null && b.getLastCompletedBuild() != null; }