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
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.88</version>
<version>5.7</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -34,8 +34,8 @@
<properties>
<changelist>999999-SNAPSHOT</changelist>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.452</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.4</jenkins.version>
<jenkins.baseline>2.479</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
</properties>

Expand All @@ -57,7 +57,7 @@
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-${jenkins.baseline}.x</artifactId>
<version>3850.vb_c5319efa_e29</version>
<version>4136.vca_c3202a_7fd1</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public boolean isChunkStart(@NonNull FlowNode current, @CheckForNull FlowNode pr
return false;
} else if (current instanceof BlockEndNode) {
return false;
} else if (current instanceof StepStartNode) {
StepStartNode startNode = (StepStartNode)current;
} else if (current instanceof StepStartNode startNode) {
if (!(startNode.getDescriptor() instanceof StageStep.DescriptorImpl)) {
return false;
}
Expand All @@ -46,9 +45,9 @@ public boolean isChunkStart(@NonNull FlowNode current, @CheckForNull FlowNode pr
@Override
public boolean isChunkEnd(@NonNull FlowNode current, @CheckForNull FlowNode previous) {
// First a block-scoped stage
if (current instanceof StepEndNode && ((StepEndNode) current).getDescriptor() instanceof StageStep.DescriptorImpl) {
if (current instanceof StepEndNode stepEndNode && stepEndNode.getDescriptor() instanceof StageStep.DescriptorImpl) {
// We have to look for the labelaction because block-scoped stage creates two nested blocks
return ((StepEndNode) current).getStartNode().getAction(LabelAction.class) != null;
return stepEndNode.getStartNode().getAction(LabelAction.class) != null;
}
// Then a marker-scoped stage
if (previous != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@
// Logic borrowed from Pipeline Stage View plugin, RuneEx
InputAction inputAction = run.getAction(InputAction.class);
if (inputAction != null) {
List<InputStepExecution> executions = null;
List<InputStepExecution> executions;
try {
executions = inputAction.getExecutions();
} catch (InterruptedException|TimeoutException ex) {
} catch (InterruptedException | TimeoutException ex) {
// Retry on timeout
try {
executions = inputAction.getExecutions();
} catch (InterruptedException|TimeoutException ex2) {
} catch (InterruptedException | TimeoutException ex2) {
// Assume we can't handle it, and default to most common state of not being an input step.
executions = null;
}
Expand Down Expand Up @@ -210,8 +210,7 @@
if (exec == null) {
return null;
}
if (chunk instanceof ParallelMemoryFlowChunk) {
ParallelMemoryFlowChunk par = ((ParallelMemoryFlowChunk) chunk);
if (chunk instanceof ParallelMemoryFlowChunk par) {

Check warning on line 213 in src/main/java/org/jenkinsci/plugins/workflow/pipelinegraphanalysis/StatusAndTiming.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 213 is only partially covered, one branch is missing
return condenseStatus(computeBranchStatuses2(run, par).values());
} else {
return computeChunkStatus2(run, chunk.getNodeBefore(), chunk.getFirstNode(), chunk.getLastNode(), chunk.getNodeAfter());
Expand Down Expand Up @@ -295,8 +294,8 @@
ErrorAction err = lastNode.getError();
if (err != null) {
Throwable rootCause = err.getError();
if (rootCause instanceof FlowInterruptedException) {
return GenericStatus.fromResult(((FlowInterruptedException) rootCause).getResult());
if (rootCause instanceof FlowInterruptedException flowInterruptedException) {
return GenericStatus.fromResult(flowInterruptedException.getResult());
} else {
return GenericStatus.FAILURE;
}
Expand Down Expand Up @@ -378,8 +377,8 @@
// Fudge
boolean isLastChunk = after == null || exec.isCurrentHead(lastNode);
if (isLastChunk && run.isBuilding()) {
if (exec.getCurrentHeads().size() > 1 && lastNode instanceof BlockEndNode) { // Check to see if all the action is on other branches
BlockStartNode start = ((BlockEndNode)lastNode).getStartNode();
if (exec.getCurrentHeads().size() > 1 && lastNode instanceof BlockEndNode blockEndNode) { // Check to see if all the action is on other branches
BlockStartNode start = blockEndNode.getStartNode();
if (start.getAction(ThreadNameAction.class) != null) {
endTime = TimingAction.getStartTime(lastNode); // Completed parallel branch, use the block end time
}
Expand Down Expand Up @@ -453,7 +452,7 @@
for (int i=0; i<branchEnds.size(); i++) {
BlockStartNode start = branchStarts.get(i);
FlowNode end = branchEnds.get(i);
if (end instanceof BlockEndNode && start != ((BlockEndNode)end).getStartNode()) {
if (end instanceof BlockEndNode blockEndNode && start != blockEndNode.getStartNode()) {

Check warning on line 455 in src/main/java/org/jenkinsci/plugins/workflow/pipelinegraphanalysis/StatusAndTiming.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 455 is only partially covered, one branch is missing
throw new IllegalArgumentException("Mismatched parallel branch start/end nodes: "
+ start.getId()+','
+ end.getId());
Expand Down Expand Up @@ -542,7 +541,7 @@
for (int i=0; i<branchEnds.size(); i++) {
BlockStartNode start = branchStarts.get(i);
FlowNode end = branchEnds.get(i);
if (end instanceof BlockEndNode && start != ((BlockEndNode)end).getStartNode()) {
if (end instanceof BlockEndNode blockEndNode && start != blockEndNode.getStartNode()) {

Check warning on line 544 in src/main/java/org/jenkinsci/plugins/workflow/pipelinegraphanalysis/StatusAndTiming.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 544 is only partially covered, one branch is missing
throw new IllegalArgumentException("Mismatched parallel branch start/end nodes: "
+ start.getId()+','
+ end.getId());
Expand Down Expand Up @@ -583,50 +582,50 @@
}
DepthFirstScanner scanner = new DepthFirstScanner();
List<FlowNode> sorted = scanner.filteredNodes(exec.getCurrentHeads(), Predicates.alwaysTrue());
sorted.sort(new Comparator<FlowNode>() {
sorted.sort(new Comparator<>() {
@Override
public int compare(FlowNode node1, FlowNode node2) {
int node1Iota = parseIota(node1);
int node2Iota = parseIota(node2);

if (node1Iota < node2Iota) {
return -1;
} else if (node1Iota > node2Iota) {
return 1;
}
return 0;
}

private int parseIota(FlowNode node) {
try {
return Integer.parseInt(node.getId());
} catch (NumberFormatException e) {
return 0;
}
}
});
System.out.println("Node dump follows, format:");
System.out.println("[ID]{parent,ids}(millisSinceStartOfRun) flowNodeClassName stepDisplayName [st=startId if a block end node]");
System.out.println("Action format: ");
System.out.println("\t- actionClassName actionDisplayName");
System.out.println("------------------------------------------------------------------------------------------");
Function<FlowNode, String> flowNodeToId = input -> input != null ? input.getId() : null;
for (FlowNode node : sorted) {
StringBuilder formatted = new StringBuilder();
formatted.append('[').append(node.getId()).append(']');
formatted.append('{').append(StringUtils.join(node.getParents().stream().map(flowNodeToId).collect(Collectors.toList()), ',')).append('}');
if (showTiming) {
formatted.append('(');
if (node.getAction(TimingAction.class) != null) {
formatted.append(TimingAction.getStartTime(node)-runStartTime);
} else {
formatted.append("N/A");
}
formatted.append(')');
}
formatted.append(node.getClass().getSimpleName()).append(' ').append(node.getDisplayName());
if (node instanceof BlockEndNode) {
formatted.append(" [st=").append(((BlockEndNode)node).getStartNode().getId()).append(']');
if (node instanceof BlockEndNode blockEndNode) {
formatted.append(" [st=").append(blockEndNode.getStartNode().getId()).append(']');

Check warning on line 628 in src/main/java/org/jenkinsci/plugins/workflow/pipelinegraphanalysis/StatusAndTiming.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 585-628 are not covered by tests
}
if (showActions) {
for (Action a : node.getActions()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public TimingInfo(long totalDurationMillis, long pauseDurationMillis, long start
this.startTimeMillis = startTimeMillis;
}

public TimingInfo(){
public TimingInfo() {
// Basic constructor
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class StageTest {
public JenkinsRule jenkinsRule = new JenkinsRule();

public static class CollectingChunkVisitor extends StandardChunkVisitor {
Deque<MemoryFlowChunk> allChunks = new ArrayDeque<>();
final Deque<MemoryFlowChunk> allChunks = new ArrayDeque<>();

public List<MemoryFlowChunk> getChunks() {
return new ArrayList<>(allChunks);
Expand Down Expand Up @@ -69,20 +69,21 @@ private static void assertChunkBoundary(FlowChunkWithContext chunk, int beforeId
public void testBlockStage() throws Exception {
WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "Blocky job");

job.setDefinition(new CpsFlowDefinition("" +
"node {" +
" stage ('Build') { " +
" echo ('Building'); " +
" } \n" +
" stage ('Test') { " +
" echo ('Testing'); " +
" } \n" +
" stage ('Deploy') { " +
" writeFile file: 'file.txt', text:'content'; " +
" archive(includes: 'file.txt'); " +
" echo ('Deploying'); " +
" } \n" +
"}", true));
job.setDefinition(new CpsFlowDefinition("""
\
node {\
stage ('Build') { \
echo ('Building'); \
}\s
stage ('Test') { \
echo ('Testing'); \
}\s
stage ('Deploy') { \
writeFile file: 'file.txt', text:'content'; \
archive(includes: 'file.txt'); \
echo ('Deploying'); \
}\s
}""", true));
/*
* Node dump follows, format:
[ID]{parent,ids} flowNodeClassName stepDisplayName [st=startId if a block node]
Expand Down
Loading