Skip to content

Instantly share code, notes, and snippets.

@tizki
Created September 28, 2017 14:41
Show Gist options
  • Save tizki/175ff0769584afd5bb65ef19d7776c54 to your computer and use it in GitHub Desktop.
Save tizki/175ff0769584afd5bb65ef19d7776c54 to your computer and use it in GitHub Desktop.
prints test class FQDN name and its duration in seconds
import hudson.tasks.test.AbstractTestResultAction;
import hudson.tasks.junit.ClassResult;
import hudson.tasks.test.TabulatedResult;
import hudson.tasks.test.TestResult;
def jenkins = Jenkins.instance
def job = jenkins.getItem("your job")
def buildNum = 123
def bld = job.getBuildByNumber(buildNum)
//println bld.actions
def testResults = bld.getAction(AbstractTestResultAction.class)
def testData = testResults.getResult()
println testData instanceof TabulatedResult
TabulatedResult tr = (TabulatedResult) testData;
for (TestResult child : tr.getChildren()) {
for( hudson.tasks.junit.ClassResult cr: child.getChildren()){
println "${child.packageName}.${cr.className}, ${cr.duration}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment