Groovy Postbuild testResultAction always null

335 views
Skip to first unread message

foolhunger Hsiao

unread,
Jan 5, 2016, 11:23:30 PM1/5/16
to Jenkins Users
Hi, all

I was trying to use groovy postbuild plugin to get test failure count, and test pass count.

But the testResultAction is always null, I have tried this on two Jenkins instances, one with version 1.6+, another 1.5+.

The script is simple:
def failCnt = manager.build.testResultAction.failCount

but throws null pointer exception since getTestResultAction is null.

The build starts with one maven build (mvn clean test, with 5 total tests, 3 failed tests), and I think the groovy script should be able to get the testResult.

Not sure what went wrong, many thanks.

Victor Martinez

unread,
Jan 6, 2016, 5:55:52 AM1/6/16
to Jenkins Users
Hi,

 Do you use the junit plugin (https://wiki.jenkins-ci.org/display/JENKINS/JUnit+Plugin) in your jenkins job?

Cheers

foolhunger Hsiao

unread,
Jan 6, 2016, 11:28:36 AM1/6/16
to Jenkins Users
Thanks Victor

I think I have found the issue, it works with maven style jobs but doesn't work with freestyle ones, not sure whether that's intentional or a bug

Maybe I should open a Jira issue for this

Victor Martinez

unread,
Jan 6, 2016, 1:14:54 PM1/6/16
to Jenkins Users
IMO, freestyle jobs don't know what a test means unless there are some post build actions to parse those *unit files, therefore you shouldn't raise a ticket since that's the expected behavior I guess so.

Cheers

foolhunger Hsiao

unread,
Jan 6, 2016, 8:43:52 PM1/6/16
to Jenkins Users
Maybe it is the way how it works, many thanks, really helps
Reply all
Reply to author
Forward
0 new messages