I'm using this kludge inside Jenkinsfile (where 'appserver' is used to namespace the test results):
sh "./mvnw verify"
def testFiles = '**/target/failsafe-reports/TEST-*.xml'
setJUnitPrefix(appserver, testFiles)
junit testFiles
}
def setJUnitPrefix(prefix, files) {
// add prefix to qualified classname
sh "shopt -s globstar && sed -i \"s/\\(<testcase .*classname=['\\\"]\\)\\([a-z]\\)/\\1${prefix.toUpperCase()}.\\2/g\" $files"
}
Naturally, a regex is a terrible way of parsing XML, but the idea of the sed script is to add the prefix to every classname attribute inside a testcase element (<testcase classname=""). I'm using failsafe's filenames here, but the general idea should work for any junit xml file, as long as classname is the first attribute in the testcase element, and on the same line. (The regex could be a little simpler, but I wanted the processing to be idempotent.)
As an example, the wildfly results for org.example.ExampleTest now appear in Jenkins as WILDFLY.org.example.ExampleTest, separated from JBOSSEAP.org.example.ExampleTest.