Permalink
Browse files

[JENKINS-46112] Test demonstrating that error steps get log actions now

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 0ca46234cefaeeda2791835b2fc9201e2997f70e
@@ -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;
@@ -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;
@@ -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.