Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid printing too long argument lists during FlowNode visualization #70

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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 @@ -39,6 +39,7 @@
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.structs.describable.DescribableModel;
import org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
Expand Down Expand Up @@ -197,7 +198,7 @@ public static String getStepArgumentsAsString(@Nonnull FlowNode n) {
StepDescriptor descriptor = ((StepNode) n).getDescriptor();
if (descriptor != null) { // Null if plugin providing descriptor was uninstalled
Map<String, Object> filteredArgs = getFilteredArguments(n);
return descriptor.argumentsToString(filteredArgs);
return StringUtils.substring(descriptor.argumentsToString(filteredArgs), 0, 80);
}
}
return null; // non-StepNode nodes can't have step arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,33 @@ private List<FlowNode> enclosingBlocksIncludingNode(FlowNode node) {
encl.addAll(node.getEnclosingBlocks());
return encl;
}
}

@Test
public void testLongStepArguments() throws Exception {
rr.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
WorkflowJob job = rr.j.createProject(WorkflowJob.class, "testLongStepArguments");

job.setDefinition(new CpsFlowDefinition(
"node('master') {\n" +
" stage('weird') {\n" +
" echo 'lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so,lib01.so'\n" +
" }\n" +
"}\n")
);
WorkflowRun r = rr.j.buildAndAssertSuccess(job);

FlowExecution execution = r.getExecution();

DepthFirstScanner scan = new DepthFirstScanner();
for (FlowNode n : scan.allNodes(execution)) {
String args = ArgumentsAction.getStepArgumentsAsString(n);
if(args!=null) {
assertTrue(args.length() <= 80);
}
}
}
});
}
}