Skip to content

Commit

Permalink
splitting out the failure count into it's own variable
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelJ committed Jun 1, 2012
1 parent 3d5b6fd commit 0040b66
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
14 changes: 10 additions & 4 deletions src/main/java/com/attask/jenkins/dashboard/Column.java
Expand Up @@ -11,31 +11,37 @@ public class Column {
public static Column EMPTY = new Column();

private final String name;
private final int failureCount;
private final String url;
private final String buildStatusUrl;
private final boolean isEmpty;
private final boolean isPassed;

private Column(String name, String url, String buildStatusUrl, boolean isEmpty) {
private Column(String name, int failureCount, String url, String buildStatusUrl, boolean isEmpty) {
this.name = name;
this.failureCount = failureCount;
this.url = url;
this.buildStatusUrl = buildStatusUrl;
this.isEmpty = isEmpty;
this.isPassed = this.buildStatusUrl.contains("blue.png");
}

public Column(String name, String url, String buildStatusUrl) {
this(name, url, buildStatusUrl, false);
public Column(String name, int failureCount, String url, String buildStatusUrl) {
this(name, failureCount, url, buildStatusUrl, false);
}

private Column() {
this("", "", "", true);
this("", -1, "", "", true);
}

public String getName() {
return name;
}

public int getFailureCount() {
return failureCount;
}

public String getUrl() {
return url;
}
Expand Down
18 changes: 7 additions & 11 deletions src/main/java/com/attask/jenkins/dashboard/PipelineDashboard.java
Expand Up @@ -186,22 +186,18 @@ public int compare(Row row1, Row row2) {
if(showBuildName && build.getDisplayName() != null) {
rowDisplayName = build.getDisplayName();
}

if(showFailureCount) {
String testResult = "";

//Only show the count if it's Successful or Unstable
// (Successful because of the Status override plugin.)
int failureCount = -1;
if(showFailureCount && (build.getResult() == Result.SUCCESS || build.getResult() == Result.UNSTABLE)) {
AbstractTestResultAction testResultAction = build.getAction(AbstractTestResultAction.class);
if(testResultAction != null) {
int failures = testResultAction.getFailCount();
// testResult += failures;
testResult = "(" + failures + " failures" + ")";
}
if(!rowDisplayName.isEmpty()) {
rowDisplayName += " ";
failureCount = testResultAction.getFailCount();
}
rowDisplayName += testResult;
}

columns.add(new Column(rowDisplayName, build.getUrl(), rootUrl + "/static/832a5f9d/images/" + ORB_SIZE + "/" + build.getBuildStatusUrl()));
columns.add(new Column(rowDisplayName, failureCount, build.getUrl(), rootUrl + "/static/832a5f9d/images/" + ORB_SIZE + "/" + build.getBuildStatusUrl()));

//noinspection StringEquality
if(displayName == rowName && build.getDescription() != null && !build.getDescription().trim().isEmpty()) { // I really do want to do reference equals and not value equals.
Expand Down
Expand Up @@ -47,6 +47,14 @@
width: 16px;
height: 16px;
}

.build .name {
padding-right: 2px;
}

.build .failureCount {
padding-left: 2px;
}
<!--
.build a {
text-decoration: none;
Expand Down Expand Up @@ -119,10 +127,17 @@
<j:forEach items="${row.getColumns()}" var="column">
<td class="build" url="${column.getUrl()}">
<j:if test="${!column.isEmpty()}">
<a href="${column.getUrl()}testReport">
<a class="status" href="${column.getUrl()}console">
<img src="${column.getBuildStatusUrl()}"/>
<span>${column.getName()}</span>
</a>
<span>
<j:if test="${column.getName().length() > -1}">
<a class="name" href="${column.getUrl()}">${column.getName()}</a>
</j:if>
<j:if test="${column.getFailureCount() > -1}">
<a class="failureCount" href="${column.getUrl()}testReport">(${column.getFailureCount()} failures)</a>
</j:if>
</span>
</j:if>
<j:if test="${column.isEmpty()}">
<span>?</span>
Expand Down

0 comments on commit 0040b66

Please sign in to comment.