Skip to content
Permalink
Browse files
fixed JENKINS-41749
  • Loading branch information
paul committed Feb 21, 2017
1 parent c9df662 commit c72fc08c3534979ac3a1cef26b0a82ac6169f484
@@ -18,14 +18,14 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>1.15</version>
<version>2.9</version>
</dependency>
</dependencies>


<properties>
<!-- Baseline Jenkins version you use to build the plugin. Users must have this version or newer to run. -->
<jenkins.version>2.7.3</jenkins.version>
<jenkins.version>2.32.2</jenkins.version>
<!-- Java Level to use. Java 7 required when using core >= 1.612 -->
<java.level>7</java.level>
<!-- Jenkins Test Harness version you use to test the plugin. -->
@@ -2,11 +2,13 @@

import hudson.Extension;
import hudson.model.*;
import hudson.scm.ChangeLogSet;
import hudson.security.Permission;
import hudson.util.RunList;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
@@ -17,10 +19,11 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

@@ -139,7 +142,7 @@ public boolean hasPermission(final Permission p) {
@Override
public String getDisplayName() {
return
"PipelineAggregator";
"Pipeline Aggregator View";
}
}

@@ -154,50 +157,73 @@ public Api getApi() {
ArrayList<Build> l = new ArrayList<Build>();
Pattern r = filterRegex != null ? Pattern.compile(filterRegex) : null;
for (Object b : builds) {
Run build = (Run) b;
Job job = build.getParent();
WorkflowRun build = (WorkflowRun) b;

WorkflowJob job = build.getParent();
// If filtering is enabled, skip jobs not matching the filter
if (r != null && !r.matcher(job.getName()).find())
if (r != null && !(r.matcher(job.getName()).find() || r.matcher(job.getParent().getFullName()).find()))
continue;
List<ChangeLogSet<? extends ChangeLogSet.Entry>> changeLogSets = ((WorkflowRun) build).getChangeSets();
Result result = build.getResult();
l.add(new Build(job.getName(),
build.getUrl(),
build.getFullDisplayName(),
build.getUrl(),
build.getNumber(),
build.getStartTimeInMillis(),
build.getDuration(),
result == null ? "BUILDING" : result.toString()));
result == null ? "BUILDING" : result.toString(), changeLogSets));
}
return l;
}


@ExportedBean(defaultVisibility = 999)
public static class Build {
@Exported
public String jobName;
@Exported
public String buildUrl;
@Exported
public String buildName;
@Exported
public String url;
@Exported
public int number;
@Exported
public long startTime;
@Exported
public long duration;
@Exported
public String result;
@Exported
public Map<String, String> changeLogSet;

public Build(String jobName,String buildUrl, String buildName, int number, long startTime, long duration, String result) {
public Build(String jobName, String buildName, String url, int number, long startTime, long duration, String result, List<ChangeLogSet<? extends ChangeLogSet.Entry>> changeLogSets) {
this.jobName = jobName;
this.buildUrl=buildUrl;
this.buildName = buildName;
this.number = number;
this.startTime = startTime;
this.duration = duration;
this.result = result;
this.url = url;

this.changeLogSet = processChanges(changeLogSets);
}

private Map<String, String> processChanges(List<ChangeLogSet<? extends ChangeLogSet.Entry>> changeLogSets) {
Map<String, String> changes = new HashMap<>();
if (changeLogSets.isEmpty()) {
return changes;
}
for (ChangeLogSet<? extends ChangeLogSet.Entry> set : changeLogSets) {
for (Object entry : set.getItems()) {
ChangeLogSet.Entry setEntry = (ChangeLogSet.Entry) entry;
String author = setEntry.getAuthor().getFullName();
String message = setEntry.getMsg();
changes.put(message, author);
}

}
return changes;
}
}

}

@@ -1,4 +1,4 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:x="jelly:xml">
<j: xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:x="jelly:xml">
<st:contentType value="text/html;charset=UTF-8" />
<j:new var="h" className="hudson.Functions"/>
${h.initPageVariables(context)}
@@ -63,4 +63,4 @@
</script>
</body>
</html>
</j:jelly>
</j:>
@@ -48,21 +48,17 @@ function reload_jenkins_build_history(tableSelector, viewUrl, buildHistorySize,
authors = '<div>'
}
buildName = val.buildName.replace(/(.*) #.*/, '$1');
url = val.buildUrl;
var url = val.url;
bame = '<a role="button" href="' + url + '" class="btn">' + buildName + '</a>';
stages = '<div class="btn-group" role="group">'
$.getJSON(url + "wfapi/describe", function (data) {
if (typeof data.stages !== 'undefined' && data.stages.length > 0) {
var changeSet = val.changeLogSet;
if (typeof data._links.changesets !== 'undefined') {
$.getJSON(data._links.changesets.href, function (data) {
for (change in data) {
for (commit in data[change].commits) {
text = '<strong>' + data[change].commits[commit].authorJenkinsId + '</strong> ' + data[change].commits[commit].message;
authors += text + '</br>';
}
}

});
for (change in changeSet) {
text = '<strong>' + changeSet[change] + '</strong> ' + change;
authors += text ;
}
} else {
authors += 'No Changes'
}

0 comments on commit c72fc08

Please sign in to comment.