Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -106,8 +107,11 @@
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner;
import org.jenkinsci.plugins.workflow.flow.GraphListener;
import org.jenkinsci.plugins.workflow.flow.StashManager;
import org.jenkinsci.plugins.workflow.graph.BlockEndNode;
import org.jenkinsci.plugins.workflow.graph.BlockStartNode;
import org.jenkinsci.plugins.workflow.graph.FlowEndNode;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graphanalysis.DepthFirstScanner;
import org.jenkinsci.plugins.workflow.job.console.NewNodeConsoleNote;
import org.jenkinsci.plugins.workflow.log.LogStorage;
import org.jenkinsci.plugins.workflow.log.TaskListenerDecorator;
Expand Down Expand Up @@ -1034,6 +1038,35 @@ private final class NodePrintListener implements GraphListener.Synchronous {
return LogStorage.of(asFlowExecutionOwner()).overallLog(this, !isLogUpdated());
}

/**
* For use by Jelly only.
*/
@Restricted(DoNotUse.class)
public String getFlowGraphDataAsHtml() {
FlowExecution exec = getExecution();
if (exec != null) {
DepthFirstScanner scanner = new DepthFirstScanner();
if (scanner.setup(exec.getCurrentHeads())) {
StringBuilder html = new StringBuilder();
for (FlowNode node : scanner) {
String startId;
String enclosingId;
if (node instanceof BlockEndNode) {
enclosingId = null;
startId = ((BlockEndNode) node).getStartNode().getId();
} else {
Iterator<BlockStartNode> it = node.iterateEnclosingBlocks().iterator();
enclosingId = it.hasNext() ? it.next().getId() : null;
startId = node instanceof BlockStartNode ? node.getId() : null;
}
html.append(NewNodeConsoleNote.startTagFor(this, node.getId(), startId, enclosingId)).append("Test</span>");
}
return html.toString();
}
}
return null;
}

// TODO log-related overrides pending JEP-207:

@Override public InputStream getLogInputStream() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ private NewNodeConsoleNote(FlowNode node) {

@Override
public ConsoleAnnotator<?> annotate(WorkflowRun context, MarkupText text, int charPos) {
StringBuilder startTag = startTagFor(context, id, start, enclosing);
text.addMarkup(0, text.length(), startTag.toString(), "</span>");
return null;
}

@Restricted(NoExternalUse.class)
public static StringBuilder startTagFor(@Nonnull WorkflowRun context, @Nonnull String id, @CheckForNull String start, @CheckForNull String enclosing) {
StringBuilder startTag = new StringBuilder("<span class=\"pipeline-new-node\" nodeId=\"").append(id);
if (start != null) {
startTag.append("\" startId=\"").append(start);
Expand All @@ -123,8 +130,7 @@ public ConsoleAnnotator<?> annotate(WorkflowRun context, MarkupText text, int ch
}
}
startTag.append("\">");
text.addMarkup(0, text.length(), startTag.toString(), "</span>");
return null;
return startTag;
}

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!--
The MIT License

Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi

Copyright (c) 2012, Martin Schroeder, Intel Mobile Communications GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<!--
Displays the console output
-->
<?jelly escape-by-default='true'?>
<st:compress xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<l:layout title="${it.fullDisplayName} Console" norefresh="true">
<st:include page="sidepanel.jelly" />
<l:main-panel>
<t:buildCaption>
Custom ${%Console Output}
</t:buildCaption>
<j:set var="threshold" value="${h.getSystemProperty('hudson.consoleTailKB')?:'150'}" />
<!-- Show at most last 150KB (can override with system property) unless consoleFull is set -->
<j:set var="offset" value="${empty(consoleFull) ? it.logText.length()-threshold*1024 : 0}" />
<j:choose>
<j:when test="${offset > 0}">
${%skipSome(offset/1024,"consoleFull")}
</j:when>
<j:otherwise>
<j:set var="offset" value="${0}" />
</j:otherwise>
</j:choose>

<j:out value="${h.generateConsoleAnnotationScriptAndStylesheet()}"/>

<j:choose>
<!-- Do progressive console output -->
<j:when test="${it.isLogUpdated()}">
<pre id="out" class="console-output" />
<div id="spinner">
<img src="${imagesURL}/spinner.gif" alt="" />
</div>
<t:progressiveText href="logText/progressiveHtml" idref="out" spinner="spinner"
startOffset="${offset}" onFinishEvent="jenkins:consoleFinished"/>
</j:when>
<!-- output is completed now. -->
<j:otherwise>
<j:if test="${offset!=0}">
<!--
When the log is truncated, we still need data about nodes that were
added to the graph before the truncation point to be present on the
page in order to be able to display parallel branch names correctly.
-->
<div id="flow-graph-data" style="display:none;">
<j:out value="${it.flowGraphDataAsHtml}"/>
</div>
</j:if>
<pre class="console-output">
<st:getOutput var="output" />
<j:whitespace>${it.writeLogTo(offset,output)}</j:whitespace>
</pre>
</j:otherwise>
</j:choose>
</l:main-panel>
</l:layout>
</st:compress>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# The MIT License
#
# Copyright (c) 2004-2009, Sun Microsystems, Inc., Alan Harder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

skipSome=Skipping {0,number,integer} KB.. <a href="{1}">Full Log</a>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ Behaviour.specify("span.pipeline-new-node", 'NewNodeConsoleNote', 0, function(e)
e.innerHTML = e.innerHTML.replace(/.+/, '$&<span class="pipeline-show-hide"> (<a href="#" onclick="showHidePipelineSection(this); return false">hide</a>)</span>')
// TODO automatically hide second and subsequent branches: namely, in case a node has the same parent as an earlier one
}
// The CSS rule for branch names only needs to be added once per node, so we
// check in case we are viewing the truncated log and have already processed
// a duplicate synthetic span element for this node.
var maybeDupeNodes = $$('[nodeid=\"'+nodeId+'\"].pipeline-new-node');
for (var i = 0; i < maybeDupeNodes.length; i++) {
var node = maybeDupeNodes[i];
if (node !== e && node.processedNewNodeConsoleNote) {
return;
}
}
var nodes = $$('.pipeline-new-node')
var enclosings = new Map() // id → enclosingId
var labels = new Map() // id → label
Expand Down Expand Up @@ -101,16 +111,16 @@ function showHidePipelineSection(link) {
var oid = ids[i]
if (oid != id && encloses(id, oid, starts, enclosings)) {
showHide(oid, display)
var header = $$('.pipeline-new-node[nodeId=' + oid + ']')
if (header.length > 0) {
header[0].style.display = display
var headers = $$('.pipeline-new-node[nodeId=' + oid + ']');
for (var j = 0; j < headers.length; j++) {
headers[j].style.display = display;
}
if (display == 'inline') {
if (display === 'inline') {
// Mark all children as shown. TODO would be nicer to leave them collapsed if they were before, but this gets complicated.
var link = $$('.pipeline-new-node[nodeId=' + oid + '] span a')
if (link.length > 0) {
link[0].textContent = 'hide'
link[0].parentNode.className = 'pipeline-show-hide'
var links = $$('.pipeline-new-node[nodeId=' + oid + '] span a');
for (var j = 0; j < links.length; j++) {
links[j].textContent = 'hide';
links[j].parentNode.className = 'pipeline-show-hide';
}
}
}
Expand Down