Navigation Menu

Skip to content

Commit

Permalink
[JENKINS-46112] Test demonstrating that error steps get log actions now
Browse files Browse the repository at this point in the history
They didn't in 1.1.9 (and probably earlier) for no reason I can figure
out, but they do now. Again, for no reason I can figure out.
  • Loading branch information
abayer committed Aug 10, 2017
1 parent 103bec1 commit 0ca4623
Showing 1 changed file with 23 additions and 0 deletions.
Expand Up @@ -43,7 +43,9 @@
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTTreeStep;
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTValue;
import org.jenkinsci.plugins.workflow.actions.ErrorAction;
import org.jenkinsci.plugins.workflow.actions.LogAction;
import org.jenkinsci.plugins.workflow.actions.TagsAction;
import org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode;
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode;
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.graph.BlockStartNode;
Expand All @@ -56,6 +58,7 @@
import org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever;
import org.jenkinsci.plugins.workflow.pipelinegraphanalysis.GenericStatus;
import org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StatusAndTiming;
import org.jenkinsci.plugins.workflow.steps.ErrorStep;
import org.junit.BeforeClass;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
Expand Down Expand Up @@ -854,4 +857,24 @@ public void parallelStagesAgentEnvWhen() throws Exception {


}

@Test
public void logActionPresentForError() throws Exception {
WorkflowRun r = expect(Result.FAILURE,"logActionPresentForError").go();
FlowExecution execution = r.getExecution();

Collection<FlowNode> heads = execution.getCurrentHeads();

DepthFirstScanner scanner = new DepthFirstScanner();

FlowNode n = scanner.findFirstMatch(heads, null, new Predicate<FlowNode>() {
@Override
public boolean apply(FlowNode input) {
return input instanceof StepAtomNode && ((StepAtomNode) input).getDescriptor() instanceof ErrorStep.DescriptorImpl;
}
});

LogAction l = n.getAction(LogAction.class);
assertNotNull(l);
}
}

0 comments on commit 0ca4623

Please sign in to comment.