Open notoriousUdo opened 3 years ago
I wonder if checks-api-plugin could perhaps detect whether the exception was caught, by comparing the exceptions of the readFile step to the exceptions propagating out from the try…catch statement. However, the screen shot says "Environment / Read file from workspace", which does not seem to mention the try…catch, so perhaps it is not treated as a step. Should check the source code.
If you make the catch clause use an exception type that does not match what is thrown, what does the output look like then? Does it show the same exception twice: once for the readFile step and again for just "Environment"?
I am surprised that the "name" from stage('name')
does not appear in the output at all.
ExceptionCause might be useful here, for finding the exception that caused the build to fail, or for detecting that an exception did not cause that.
I tried this and did not see any workflow node for the try…catch. There was no ExceptionCause in build.xml or workflow/*.xml, either.
Looking at the FlowGraphTable in Script Console:
import org.jenkinsci.plugins.workflow.graph.FlowNode
import org.jenkinsci.plugins.workflow.support.visualization.table.FlowGraphTable
Run build = Jenkins.get().getItemByFullName("REDACTED").getBuild("3")
FlowGraphTable table = new FlowGraphTable(build.getExecution())
table.build()
for (FlowGraphTable.Row row : table.getRows()) {
FlowNode startNode = row.getNode()
FlowNode endNode = row.endNode // private field :(
println("depth=${row.getTreeDepth()} ${startNode.getDisplayName()} ${startNode.getError()?.getDisplayName()}")
if (endNode != null) {
println("\t${endNode.getDisplayName()} ${endNode.getError()?.getDisplayName()}")
}
}
catch (NullPointerException e)
did not match the type), the ErrorAction was copied to each StepEndNode and FlowEndNode on the way out. I did not test how this would have been formatted for status checks.When FlowExecutionAnalyzer finds an ErrorAction in a table row, it could check all table rows at outer depths. If any of those has an end node that does not have any errors, then consider the error handled and suppress it from the output. Complications:
finally
clause could run more successful steps in between, and a catch
clause could throw a different exception that is regardless caused by the original error. If it is not clear whether the error was handled, it seems best to show the error.Alternatives that would not require examining the end nodes:
In any case, the fix would be in FlowExecutionAnalyzer in checks-api-plugin, not in github-checks-plugin.
We're running our pipelines with a Jenkinsfile and a custom groovy-library that is tailored for our infrastructure. In this library we have defined a couple of exceptions to handle such cases to not immediately fail the pipeline
However, when looking at the GitHub check details these exceptions are still being reported. The picture below shows such a case where the
java.nio.file.NoSuchFileException
is gracefully handled by our library, but its still being reported as an error:This is confusing for our users.
Version report
Jenkins and plugins versions report:
Reproduction steps
Results
Expected result:
Check report success and nothing else ( since the pipeline handled the error)
Actual result: