Result
<%if(pipeline.failed) {%>
Failed in stage <%=stages.flatten().reverse().find { list -> list.find {!it.succeeded} }?.context?.stageName%>
<%} else {%>
Succeeded
<%}%>
Timeline
<%stages.each { branch -> %>
<%long totalTimeMs = branch*.context*.documentation.grep{it != null}.sum{ it.elapsedMs?:0 }; int count=0; int branchCount=0;%>
<%def widths=[] %>
<%branch.each { stage -> def ctx = stage.context;
def width = (ctx.documentation.elapsedMs?:0)/(float)totalTimeMs*100;
if(width<5.0)
width=5.0f
widths << width;
}
// width can be greater than 100%, so scale here:
def total = widths.sum()
widths = widths.collect { it / (total/100.0f) }
// Make sure the last width is right aligned
if(widths)
widths[-1] += 100.0f - widths.sum() + 1.0f
%>
<%
float left = 0;
branch.each { stage -> def ctx = stage.context; branchCount++; %>
class='timeblock <%if(!stage.succeeded){%>failed<%}%> <%=(branch && stage==branch[-1])?"right":""%>'
style='left: ${left}%; width: ${width-1}%'>
<%
// Just a heuristic here, we roughly assume 1% width per char (for 1024px, 10px char width)
// So truncate when text is wider than that. The -1 nudges it down for the extreme case
// so that the minimum 5% only gets 4 characters before truncation
%>
<%=bpipe.Utils.truncnl(ctx.stageName,(int)(width-1))%>
<% left += width %>
<%}%>
<%count = 0 %>
<%left = 0 %>
<%branch*.context.each { stage -> %>
class='timeblock duration' style='left: ${left}%; width: ${width-1}%'>
<%if(stage.documentation?.finishedAt) {%>
<% use(groovy.time.TimeCategory) { %>
<%=(stage.documentation.finishedAt - stage.documentation.startedAt).toString().replaceAll('seconds','s').replaceAll('minutes','mins')%>
<% } %>
<% } %>
<% left += width %>
<%}%>
<%}%>
Pipeline Stages
<% int branchCount = 0; %>
<%stages.each { branch -> ++branchCount; %>
<%if(stages.size()>1) {%>
Branch ${branchCount}
<%}%>
<%branch.each { stage -> def ctx = stage.context; %>
-
<%if(ctx.documentation) {%>
<% def doc = ctx.documentation; %>
<%if(doc.desc) {%>
${doc.desc}
<%}%>
<%if(doc.author) {%>
Author |
${doc.author} |
<%}%>
<%if(doc.inputs || ctx.inputs) {%>
Inputs |
<%if(ctx.inputs) {%>
|
<%} else {%>
<% if(doc.inputs instanceof List) { %>
<% } else { %>
| ${doc.inputs} |
<% } %>
<% } %>
<%}%>
Commands | ${ctx.trackedOutputs.keySet().join(" ")} |
<%if(doc.outputs || ctx.outputs) {%>
Outputs |
<% if(ctx.outputs) { %>
<%ctx.outputs.each { output ->%>
- ${output.replaceAll("^\\./","")}
<%}%>
|
<% } else { %>
<% if(doc.outputs instanceof List) { %>
<% doc.outputs.each { inp -> %>
- ${inp}
<% } %>
|
<% } else { %>
${doc.outputs} |
<% } %>
<% } %>
<%}%>
<%if(doc.tools) {%>
Tools |
|
<%}%>
<%if(doc?.constraints) {%>
Constraints |
${doc.constraints} |
<%}%>
<%if(doc.startedAt) {%>
Execution Time |
<%if(doc.elapsedMs<1000 || !doc.finishedAt) { %>
${dateFormat.format(doc.startedAt)}
<% } else {%>
${dateFormat.format(doc.startedAt)} - ${dateFormat.format(doc.finishedAt)}
<% } %>
<%if(doc.finishedAt) use(groovy.time.TimeCategory) { %>
(${doc.finishedAt - doc.startedAt})
<% } %>
|
<%}%>
<%}%>
<%}%>
<%}%>