More generally, contrary to JENKINS-35308, there are missing line numbers in errors. For example, if a tool step fails buried deep in some library, you just see
[Pipeline] End of Pipeline
ERROR: No tool named … found
Finished: FAILURE
Even the ErrorAction in the workflow/*.xml corresponding to the FlowEndNode is not helpful here:
<org.jenkinsci.plugins.workflow.actions.ErrorAction plugin="workflow-api@2.1">
<error class="hudson.AbortException">
<detailMessage>No tool named null found</detailMessage>
<stackTrace>
<trace>org.jenkinsci.plugins.workflow.steps.ToolStep$Execution.run(ToolStep.java:137)</trace>
<trace>org.jenkinsci.plugins.workflow.steps.ToolStep$Execution.run(ToolStep.java:111)</trace>
<trace>org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:52)</trace>
<trace>hudson.security.ACL.impersonate(ACL.java:213)</trace>
<trace>org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49)</trace>
<trace>java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)</trace>
<trace>java.util.concurrent.FutureTask.run(FutureTask.java:266)</trace>
<trace>java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)</trace>
<trace>java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)</trace>
<trace>java.lang.Thread.run(Thread.java:745)</trace>
</stackTrace>
<suppressedExceptions class="java.util.Collections$UnmodifiableRandomAccessList" resolves-to="java.util.Collections$UnmodifiableList">
<c class="list"/>
<list reference="../c"/>
</suppressedExceptions>
</error>
</org.jenkinsci.plugins.workflow.actions.ErrorAction>
Perhaps ErrorAction should include a second field encoding the stack trace of the StepExecution.start invocation, so we can track it back to a source line number. Or perhaps this could be added as a cause or suppressed exception in CpsStepContext.onFailure, so it appears automatically whenever printStackTrace is called, though this then breaks down when WorkflowRun.finish etc. handle AbortException specially.
Another option is for every StepAtomNode/StepStartNode to encode a SourceLocation, which would enable the RFE originally requested here. Not clear to me how to get access to that location from DSL though. CpsThread.current().getStackTrace() perhaps?
More generally, contrary to JENKINS-35308, there are missing line numbers in errors. For example, if a tool step fails buried deep in some library, you just see
Even the ErrorAction in the workflow/*.xml corresponding to the FlowEndNode is not helpful here:
Perhaps ErrorAction should include a second field encoding the stack trace of the StepExecution.start invocation, so we can track it back to a source line number. Or perhaps this could be added as a cause or suppressed exception in CpsStepContext.onFailure, so it appears automatically whenever printStackTrace is called, though this then breaks down when WorkflowRun.finish etc. handle AbortException specially.
Another option is for every StepAtomNode/StepStartNode to encode a SourceLocation, which would enable the RFE originally requested here. Not clear to me how to get access to that location from DSL though. CpsThread.current().getStackTrace() perhaps?