I am trying to use import hudson.tasks.junit.TestResult to get the count of Junit tests from a downstream job and unable to get count.
Expected: Able to pull count from downstream.
Actual: testResultaction
is null always.
stage ('Starting Smoke Check') {
steps{
script {
echo 'Staring Health Check'
def jobBuild = build job:'JI',parameters:[]
def jobResult = jobBuild.getResult()
echo "Build returned result: ${jobResult}"
def log = jobBuild.rawBuild.log
echo "===================START LOG==================="
println("Build log: ${log}")
TestResult testResultAction = jobBuild.rawBuild.getAction(TestResult.class)
println "TestResult Action: ${testResultAction}"
if (testResultAction != null) {
def totalNumberOfTests = testResultAction.getTotalCount()
def failedNumberOfTests = testResultAction.getFailCount()
def skippedNumberOfTests = testResultAction.getSkipCount()
def passedNumberOfTests = totalNumberOfTests - failedNumberOfTests - skippedNumberOfTests
echo "Tests Report:\n Passed: ${passedNumberOfTests}; Failed: ${failedNumberOfTests} ${failedDiff}; Skipped: ${skippedNumberOfTests} out of ${totalNumberOfTests} "
}
echo 'Health Check completed successfully!!'
}
}
}