I am not sure this is possible but here are my current results grab and composed to an email body,
@NonCPS
def getTestResults(ip, currentBuild)
{
def body = """Oh no, something happened to your test for ${ip}"""
AbstractTestResultAction testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
def total, failed, skipped, passed = 0
if (testResultAction != null)
{
total = testResultAction.totalCount
failed = testResultAction.failCount
skipped = testResultAction.skipCount
passed = total - failed - skipped
body = """System ${ip} \n Tests: \n $failed failed | $passed passed | $skipped skipped \n Check console output at: ${env.BUILD_URL}""" ;
}
return body
}
What I'm hoping to show in the email is if a failure happened on a test that passed on the last run, this can be seen in the Junit chart in Jenkins but so far I have failed to find a way to access this data in my groovy pipeline. Here is the rest of my code results block,
stage('Results')
{
timeout(time: 15, unit: 'MINUTES')
{
junit '*.xml'
def body = getTestResults(ip, currentBuild)
String emailTo = 'mail' ;
def subject = "Jenkins"
def providers = [[$class: 'CulpritsRecipientProvider'], [$class:'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']]
emailext to: emailTo, recipientProviders: providers, compressLog: true, subject: subject, body: body
currentBuild.result = 'SUCCESS'
}
}
Edit: I meant to add a picture of what I'm after, Data