Skip to content

Commit

Permalink
Merge pull request #31 from pcardos/make_build_parameters_visible
Browse files Browse the repository at this point in the history
Make the build parameters visible in the graph
  • Loading branch information
pskumar448 authored May 10, 2017
2 parents ad819eb + cd5fac4 commit 73fc035
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.model.BallColor;
import hudson.model.ParameterValue;
import hudson.model.ParametersAction;
import hudson.model.Run;

import java.io.Serializable;
import java.text.DateFormat;
import java.util.LinkedList;
import java.util.List;

/**
* A wrapper on a AbstractBuild that maintains additional layout information, used during graphical rendering.
Expand Down Expand Up @@ -44,6 +48,8 @@ public class BuildExecution implements Serializable {
private int displayColumn;

private int displayRow;

private List<String> parameters = null;

public BuildExecution(Run build, int buildIndex) {
this.build = build;
Expand All @@ -63,6 +69,24 @@ public BuildExecution(Run build, int buildIndex) {
this.building = this.getBuildFromUtil().isBuilding();
this.durationString = this.getBuildFromUtil().getDurationString();
this.buildSummaryStatusString = this.getBuildFromUtil().getBuildStatusSummary().message;

// If this build has parameters then get useful Strings out to be displayed in the graph.
ParametersAction parameters = this.getBuildFromUtil().getAction(ParametersAction.class);
if (parameters != null) {
this.parameters = new LinkedList<String>();
for (ParameterValue p: parameters.getParameters()) {
if (p != null) {
// The String and Boolean parameters are the most useful to display and they
// are prefixed by "(Type) ", so chop that off, and add the rest in.
String paramString = p.toString();
if (paramString.startsWith("(") && paramString.indexOf(" ") != -1) {
this.parameters.add(paramString.substring(paramString.indexOf(" ")+1));
} else {
this.parameters.add(paramString);
}
}
}
}
}

public BuildExecution(int buildIndex) {
Expand Down Expand Up @@ -153,6 +177,10 @@ private Run getBuildFromUtil() {
}
return this.build;
}

public List<String> getParameters() {
return parameters;
}

@Override
public boolean equals(Object obj) {
Expand All @@ -169,4 +197,4 @@ public int hashCode() {
}
return super.hashCode();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public String getBuildGraph() throws InterruptedException, ExecutionException, C
BuildGraphNodeModel buildGraphNodeModel = new BuildGraphNodeModel();
buildGraphNodeModel.setNodeId(item.getId());
buildGraphNodeModel.setBuildUrl(item.getBuildUrl());
buildGraphNodeModel.setParameters(item.getParameters());
buildGraphNodeModel.setRow(item.getDisplayRow());
buildGraphNodeModel.setColumn(item.getDisplayColumn());
buildGraphNodeModel.setColor(item.getIconColor().getHtmlBaseColor());
Expand Down Expand Up @@ -247,4 +248,3 @@ public String toString() {
}
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jenkinsci.plugins.buildgraphview;

import java.util.List;

public class BuildGraphNodeModel {
private String nodeId;
private int row;
Expand All @@ -19,7 +21,8 @@ public class BuildGraphNodeModel {
private String hourglasspng;
private String terminalpng;
private String timeStampString;

private List<String> parameters;

public String getNodeId() {
return nodeId;
}
Expand Down Expand Up @@ -163,4 +166,12 @@ public String getTimeStampString() {
public void setTimeStampString(String timeStampString) {
this.timeStampString = timeStampString;
}
}

public void setParameters(List<String> parameters) {
this.parameters = parameters;
}

public List<String> getParameters() {
return parameters;
}
}
10 changes: 9 additions & 1 deletion src/main/webapp/scripts/buildgraph-nodetemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
<img title="view console output" alt="console"
ng-src="{{node.terminalpng}}"/>
</a>
<br/>
<div ng-show="node.parameters != null">
Parameters:
<div ng-repeat="parameter in node.parameters">
{{parameter}}
</div>
</div>
<br/>
</div>
<div ng-show="node.started == true && node.running == true">
<img title="Started" alt="Started" ng-src="{{node.clockpng}}"/>{{node.timeStampString}} ago<br/>
Expand All @@ -43,4 +51,4 @@
</div>
</div>
</li>
</ul>
</ul>

0 comments on commit 73fc035

Please sign in to comment.