提交 6994fa04 编写于 作者: K kohsuke

fixed NPE when no build has run yet.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1727 71c3de6d-444a-0410-be80-ed276b4c234a
上级 4e61aebe
......@@ -32,6 +32,7 @@ import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import java.awt.Color;
import java.awt.Paint;
import java.io.File;
......@@ -558,6 +559,10 @@ public abstract class Job<JobT extends Job<JobT,RunT>, RunT extends Run<JobT,Run
* Returns the graph that shows how long each build took.
*/
public void doBuildTimeGraph( StaplerRequest req, StaplerResponse rsp ) throws IOException {
if(getLastBuild()==null) {
rsp.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
if(req.checkIfModified(getLastBuild().getTimestamp(),rsp))
return;
ChartUtil.generateGraph(req,rsp, createBuildTimeTrendChart(),500,400);
......@@ -568,6 +573,10 @@ public abstract class Job<JobT extends Job<JobT,RunT>, RunT extends Run<JobT,Run
* Loaded lazily by AJAX.
*/
public void doBuildTimeGraphMap( StaplerRequest req, StaplerResponse rsp ) throws IOException {
if(getLastBuild()==null) {
rsp.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
if(req.checkIfModified(getLastBuild().getTimestamp(),rsp))
return;
ChartUtil.generateClickableMap(req,rsp, createBuildTimeTrendChart(),500,400);
......
......@@ -3,37 +3,44 @@
<l:layout title="Build time trend">
<st:include page="sidepanel.jelly" />
<l:main-panel>
<div align="center">
<img src="buildTimeGraph" width="500" height="400" lazymap="buildTimeGraphMap"/>
</div>
<j:choose>
<j:when test="${it.builds.size()&gt;1">
<div align="center">
<img src="buildTimeGraph" width="500" height="400" lazymap="buildTimeGraphMap"/>
</div>
<j:set var="isMasterSlaveEnabled" value="${!empty(app.slaves)}"/>
<div align="center">
<table class="sortable" style="margin-top:1em;">
<tr>
<th initialSortDir="up">Build</th>
<th>Duration</th>
<j:if test="${isMasterSlaveEnabled}">
<th>Slave</th>
</j:if>
</tr>
<j:forEach var="r" items="${it.builds}">
<tr>
<td>
${r.displayName}
</td>
<td data="${r.duration}">
${r.durationString}
</td>
<j:if test="${isMasterSlaveEnabled}">
<td>
<t:node value="${r.builtOn}"/>
</td>
</j:if>
</tr>
</j:forEach>
</table>
</div>
<j:set var="isMasterSlaveEnabled" value="${!empty(app.slaves)}"/>
<div align="center">
<table class="sortable" style="margin-top:1em;">
<tr>
<th initialSortDir="up">Build</th>
<th>Duration</th>
<j:if test="${isMasterSlaveEnabled}">
<th>Slave</th>
</j:if>
</tr>
<j:forEach var="r" items="${it.builds}">
<tr>
<td>
${r.displayName}
</td>
<td data="${r.duration}">
${r.durationString}
</td>
<j:if test="${isMasterSlaveEnabled}">
<td>
<t:node value="${r.builtOn}"/>
</td>
</j:if>
</tr>
</j:forEach>
</table>
</div>
</j:when>
<j:otherwise>
More than 1 builds are needed for the trend report.
</j:otherwise>
</j:choose>
</l:main-panel>
</l:layout>
</j:jelly>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册