不幸的是,这里的大部分HTML都很难兼容Outlook受限的HTML支持。
<%
def paddingForDepth(int depth)
{
return "padding-left:${depth * 30}px";
}
def insertErrorPaneRow(int depth, Closure contents)
{
%>
<tr class="${tableLineClass()}">
<td class="icon_cell"></td>
<td class="console_cell"></td>
<td class="phase_name_cell" style="${paddingForDepth(depth)}">
<table width="100%" class="errorsPane">
<%
contents()
%>
</table>
</td>
</tr>
<%
}
def insertConsoleSummary(def build, int depth)
{
if (build.result != hudson.model.Result.FAILURE)
return;
final BeforeSummary = 0
final SummaryStarted = 1
final SummaryEnded = 2
BufferedReader logReader = new BufferedReader(build.getLogReader());
List<String> errorLines = new LinkedList<String>();
List<String> errorSummary = new LinkedList<String>();
Boolean msBuildDetected = false;
int scanStage = BeforeSummary;
try
{
for (String line = logReader.readLine(); line != null; line = logReader.readLine())
{
if (line.contains(' error ') || line.contains(' warning '))
errorLines.add(line);
if (line.contains('Microsoft (R) Build Engine version '))
msBuildDetected = true;
if (msBuildDetected)
{
switch (scanStage)
{
case BeforeSummary:
if (line.equals('Build FAILED.') || line.equals('Build succeeded.'))
scanStage = SummaryStarted;
if (line.equals('Attempting to cancel the build...'))
{
scanStage = SummaryEnded;
msBuildDetected = false;
}
break;
case SummaryStarted:
if (line ==~ /^\s*\d+ Warning\(s\)/)
scanStage = SummaryEnded;
else
errorSummary.add(line);
break;
}
}
}
}
finally
{
logReader.close();
}
if ((msBuildDetected && (errorSummary.size() > 0)) || (errorLines.size() > 0))
{
insertErrorPaneRow(depth) {
%><tr><td><pre><%
if (msBuildDetected)
errorSummary.each { l -> println l }
else
errorLines.each { l -> println l }
%></pre></td></tr><%
}
}
}
%>
<STYLE>
.icon_cell { padding: 3px; padding-left: 5px; padding-right: 5px; height:16px; vertical-align:middle; }
.console_cell { padding: 3px; padding-left: 5px; padding-right: 15px; height:16px; vertical-align:middle; }
.phase_name_cell { height:16px; vertical-align:middle; }
.errorsPane { background-color:#ffe0e0; }
</STYLE>
<BODY>
<!-- CONSOLE OUTPUT -->
<TABLE width="100%">
<TR><TD class="bg1"><B>BUILD SUMMARY</B></TD></TR>
</TABLE>
<BR/>
<table border="0" class="phasesTable"><tbody>
<%
insertConsoleSummary(build, 0);
%>
</tbody></table>
<BR/>
</BODY>
我期待着做同样的事情。你有没有想出一个groovy脚本来读取构建输出日志并显示提取的警告/错误? – 2016-01-25 13:59:59