Trouble Accessing JUnit Test Results in Pipeline Build

I am attempting to include test case passed, failed, skipped counts in Slack notifications from a Pipeline build but am having no success in accessing test results for a given build.

testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
 This script does not fail but I get no results back. On inspection, I can see that currentBuild.rawBuild is always NULL. 
I want to get the counts in this fashion:
        def total = testResultAction.getTotalCount()
        def failed = testResultAction.getFailCount()
        def skipped = testResultAction.getSkipCount()
 The approach below: 
AggregatedTestResultAction testResultAction = currentBuild.rawBuild.getAction(AggregatedTestResultAction.class)


hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper.getAction() is applicable for argument types: (java.lang.Class) values: [class hudson.tasks.test.AggregatedTestResultAction]
 Any input on what I'm doing wrong here would be most appreciated.


1 comment

  • 0
    Denys Digtiar

    The last error looks like the `getAction()` was called on the `currentBuild` and not on the `currentBuild.rawBuild`. This won't work since actions are not exposed to Pipeline as is.

    A new Build object should be created the moment build start. `currentBuild` is a wrapper around `currentBuild.rawBuild`. Hence, the raw build should not be NULL. More likely testResultAction is empty. 

    Given the amount of uncertainty, if you are CloudBees customer, feel free to raise a ticket so that we can better assist. Please don't to attach a Support Bundle and a test Pipeline. Thank you!

Please sign in to leave a comment.