我最終下載並修改了Violations插件代碼,以顯示沒有源代碼的文件的違規表,然後重新編譯Violations插件(並手動將我修改後的插件加載到Jenkins中)。
的文件名也沒有顯示出來,你可以用我原來的截圖中看到,該「getFileNameAlt」功能只是得到正確的名稱和「文件:$ {} it.fileNameAlt」行下面顯示的果凍腳本它(請參閱下面的截圖鏈接)。
添加以下到〜\侵犯的\ src \主\ java的\哈德森\插件\ \侵犯渲染\ FileModelProxy.java,渲染表:
public String getFileNameAlt() {
return new File(fileModel.getDisplayName()).getName();
}
public String getSummaryTable() {
StringBuilder gst = new StringBuilder();
int count = 0;
gst.append(" <table class='violations' width='100%'>\n");
gst.append(" <tr>\n");
gst.append(" <td class='violations-header'> # </td>\n");
gst.append(" <td class='violations-header'> Type </td>\n");
gst.append(" <td class='violations-header'> Class</td>\n");
gst.append(" <td class='violations-header'> Message</td>\n");
gst.append(" <td class='violations-header'> Description</td>\n");
gst.append(" </tr>\n");
Set<Violation> violations = fileModel.getLineViolationMap().get(0);
for (Violation v: violations) {
++count;
gst.append(" <tr>\n");
gst.append(" <td class='violations'>");
gst.append(count);
gst.append("</td>\n");
gst.append(" <td class='violations'>");
gst.append(v.getType());
gst.append("</td>\n");
gst.append(" <td class='violations'>");
gst.append(v.getSource());
gst.append("</td>\n");
gst.append(" <td class='violations'>");
gst.append(v.getMessage());
gst.append("</td>\n");
gst.append(" <td class='violations'>");
gst.append(v.getPopupMessage());
gst.append("</td>\n");
gst.append(" </tr>\n");
}
//}
gst.append(" </table>\n");
gst.append("<p><br>\n");
gst.append("<h3>Total Number of violations: \n");
gst.append(count);
gst.append("</h3><p>\n");
return gst.toString();
}
再更新了〜\違規\ target \ classes \ hudson \ plugins \ violations \ render \ FileModelProxy \ index.jelly文件將它添加到源代碼中會顯示違規的代碼上面(這對我來說很有用),它是下面的「」摘要行:
<j:set
var="iconDir"
value="${rootURL}/plugin/violations/images/16x16"/>
<j:set var="href" value="${it.showLines}"/>
<h1><img src="${image}"/> File: ${it.fileNameAlt}</h1>
<j:out value="${it.summaryTable}"/>
<j:forEach var="t" items="${model.typeMap.entrySet()}">
<table class="pane">
<tbody>
<tr><td class="pane-header" colspan="5"><j:out value="${it.typeLine(t.key)}"/></td></tr>
<j:forEach var="v" items="${t.value}">
<tr>
<td class="pane">
<j:if test="${href}">
<a href="#line${v.line}">${v.line}</a>
</j:if>
<j:if test="${!href}">
${v.line}
</j:if>
</td>
<!--<td class="pane">${v.source}</td> -->
<td class="pane"><j:out value="${it.severityColumn(v)}"/></td>
<td class="pane" width="99%">${v.message}</td>
</tr>
</j:forEach>
</tbody>
</table>
<p></p>
</j:forEach>
最後我玩了一下style.css文件,加入被稱爲「違規」表格樣式定義(〜\侵犯\目標\侵犯\ CSS \ style.css中):
.violations {
margin-top: 4px;
}
.violations td {
padding: 4px 4px 3px 4px;
}
table.violations {
width: 100%;
border-collapse: collapse;
border: 1px #bbb solid;
}
table.violations > tbody > tr > td:last-child {
border-right: 1px #bbb solid;
}
td.violations {
border: 1px #bbb solid;
padding: 3px 4px 3px 4px;
vertical-align: middle;
}
td.violations-header {
border: 1px #bbb solid;
border-right: none;
border-left: none;
background-color: #f0f0f0;
font-weight: bold;
}
th.violations {
border: 1px #bbb solid;
font-weight: bold;
}
下面的圖片顯示所得到的表不具有源代碼的文件。在我的情況下,文件不「的.cs」
http://i.stack.imgur.com/StChP.jpg
你提供的路徑,你的源文件在‘源路徑模式’結束?它在項目配置中的Violations插件設置的最後。 – Petrik 2013-04-15 19:59:45
應該在原始問題中包含該信息。我現在使用Violations插件版本0.7.15運行Jenkins 1.514。 – 2013-05-16 15:12:18