diff --git a/pom.xml b/pom.xml index cf41bb2..a994fc5 100644 --- a/pom.xml +++ b/pom.xml @@ -94,9 +94,9 @@ - org.jvnet.hudson.tools + org.jenkins-ci.tools maven-hpi-plugin - 3.0.1 + 2.0 true true @@ -104,7 +104,7 @@ maven-scm-plugin - 1.9 + 1.9.5 ${project.artifactId}-${project.version} diff --git a/src/main/java/com/ooyala/jenkins/plugins/pipelineaggregatorview/PipelineAggregator.java b/src/main/java/com/ooyala/jenkins/plugins/pipelineaggregatorview/PipelineAggregator.java index cc3ee5a..2cb514d 100644 --- a/src/main/java/com/ooyala/jenkins/plugins/pipelineaggregatorview/PipelineAggregator.java +++ b/src/main/java/com/ooyala/jenkins/plugins/pipelineaggregatorview/PipelineAggregator.java @@ -40,14 +40,8 @@ public class PipelineAggregator extends View { private int buildHistorySize; private boolean useCondensedTables; - - public boolean isUseScrollingCommits() { - return useScrollingCommits; - } - - public void setUseScrollingCommits(boolean useScrollingCommits) { - this.useScrollingCommits = useScrollingCommits; - } + + private boolean onlyLastBuild; private boolean useScrollingCommits; @@ -60,6 +54,7 @@ public PipelineAggregator(String name, String viewName) { this.fontSize = 16; this.buildHistorySize = 16; this.useCondensedTables = false; + this.onlyLastBuild = false; this.filterRegex = null; } @@ -88,6 +83,22 @@ public boolean isUseCondensedTables() { return useCondensedTables; } + public boolean isUseScrollingCommits() { + return useScrollingCommits; + } + + public void setUseScrollingCommits(boolean useScrollingCommits) { + this.useScrollingCommits = useScrollingCommits; + } + + public boolean isOnlyLastBuild() { + return onlyLastBuild; + } + + public void setOnlyLastBuild(boolean onlyLastBuild) { + this.onlyLastBuild = onlyLastBuild; + } + public String getTableStyle() { return useCondensedTables ? "table-condensed" : ""; } @@ -103,6 +114,7 @@ protected void submit(StaplerRequest req) throws ServletException, IOException { this.buildHistorySize = json.getInt("buildHistorySize"); this.useCondensedTables = json.getBoolean("useCondensedTables"); this.useScrollingCommits = json.getBoolean("useScrollingCommits"); + this.onlyLastBuild = json.getBoolean("onlyLastBuild"); if (json.get("useRegexFilter") != null) { String regexToTest = req.getParameter("filterRegex"); try { @@ -155,18 +167,26 @@ public Collection getBuildHistory() { Pattern r = filterRegex != null ? Pattern.compile(filterRegex) : null; List fJobs = filterJobs(jobs, r); List l = new ArrayList(); - RunList builds = new RunList(fJobs).limit(buildHistorySize); - for ( WorkflowRun build : builds){ - List> changeLogSets = ((WorkflowRun) build).getChangeSets(); - Result result = build.getResult(); - l.add(new Build(build.getDisplayName(), - build.getFullDisplayName(), - build.getUrl(), - build.getNumber(), - build.getStartTimeInMillis(), - build.getDuration(), - result == null ? "BUILDING" : result.toString(), changeLogSets)); - } + List wfr = new ArrayList(); + if( !this.onlyLastBuild ) { + RunList builds = new RunList(fJobs).limit(buildHistorySize); + for ( WorkflowRun build : builds){ + wfr.add(build); + } + } else { + for(WorkflowJob job : fJobs) { + wfr.add(job.getLastBuild()); + } + } + if( wfr != null && wfr.size() > 0 ) { + for (WorkflowRun build : wfr) { + List> changeLogSets = ((WorkflowRun) build).getChangeSets(); + Result result = build.getResult(); + l.add(new Build(build.getDisplayName(), build.getFullDisplayName(), build.getUrl(), build.getNumber(), + build.getStartTimeInMillis(), build.getDuration(), result == null ? "BUILDING" : result.toString(), + changeLogSets)); + } + } return l; } diff --git a/src/main/resources/com/ooyala/jenkins/plugins/pipelineaggregatorview/PipelineAggregator/configure-entries.jelly b/src/main/resources/com/ooyala/jenkins/plugins/pipelineaggregatorview/PipelineAggregator/configure-entries.jelly index ca09f23..8e15bb3 100644 --- a/src/main/resources/com/ooyala/jenkins/plugins/pipelineaggregatorview/PipelineAggregator/configure-entries.jelly +++ b/src/main/resources/com/ooyala/jenkins/plugins/pipelineaggregatorview/PipelineAggregator/configure-entries.jelly @@ -20,5 +20,8 @@ + + + \ No newline at end of file diff --git a/src/main/resources/com/ooyala/jenkins/plugins/pipelineaggregatorview/PipelineAggregator/index.jelly b/src/main/resources/com/ooyala/jenkins/plugins/pipelineaggregatorview/PipelineAggregator/index.jelly index dae2b29..1ac46b0 100644 --- a/src/main/resources/com/ooyala/jenkins/plugins/pipelineaggregatorview/PipelineAggregator/index.jelly +++ b/src/main/resources/com/ooyala/jenkins/plugins/pipelineaggregatorview/PipelineAggregator/index.jelly @@ -50,9 +50,10 @@ var nodeStatuses = []; var buildHistorySize = ${it.buildHistorySize}; var useScrollingCommits= ${it.useScrollingCommits}; + var onlyLastBuild= ${it.onlyLastBuild}; var rollingCommits = false; function reload_info (interval) { - reload_jenkins_build_history('#jenkinsBuildHistory', jenkinsUrl + '/${it.url}', buildHistorySize, useScrollingCommits); + reload_jenkins_build_history('#jenkinsBuildHistory', jenkinsUrl + '/${it.url}', buildHistorySize, useScrollingCommits, onlyLastBuild); setTimeout(function(){ reload_info(interval); }, interval); } diff --git a/src/main/webapp/js/pipeline-aggregator.js b/src/main/webapp/js/pipeline-aggregator.js index 6792475..8d12b61 100755 --- a/src/main/webapp/js/pipeline-aggregator.js +++ b/src/main/webapp/js/pipeline-aggregator.js @@ -30,7 +30,7 @@ function format_interval(iv) { return ivStr; } -function reload_jenkins_build_history(tableSelector, viewUrl, buildHistorySize, useScrollingCommits) { +function reload_jenkins_build_history(tableSelector, viewUrl, buildHistorySize, useScrollingCommits, onlyLastBuild) { $.getJSON(viewUrl + 'api/json', function (data) { // Remove all existing rows $(tableSelector + ' tbody').find('tr').remove();