Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-49339

Add ability to get test results for a given Maven execution

      The problem is that our Jenkins file is using parallel() and executes several maven builds (using withMaven).

      We then have some custom logic after each maven execution to analyze failing tests. The problem is that they accumulate in "currentBuild" and we cannot find the tests related to the maven execution that just happened.

      FYI the way we retrieve failing tests is:

      AbstractTestResultAction testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
      def failedTests = testResultAction.getResult().getFailedTests()
      

      See also https://groups.google.com/forum/?nomobile=true#!topic/jenkinsci-users/dDDPC486JWE

      I've tried to put some logic to save failing tests before and after each maven execution but it cannot work because of "parallel" (all maven executions starting in parallel save an empty state of failing tests and as soon as one of them gets a failing test, they'll all report it failing and send duplicate emails):

      So right now we're stuck and missing a way to get the test result for a single maven execution.

      Thanks

          [JENKINS-49339] Add ability to get test results for a given Maven execution

          Vincent Massol created issue -
          Vincent Massol made changes -
          Comment [ I forgot to mention that our various maven execution execute the same tests (but under different conditions). ]
          Vincent Massol made changes -
          Description Original: The problem is that our Jenkins file is using parallel() and executes several maven builds (using withMaven).

          We then have some custom logic after each maven execution to analyze failing tests. The problem is that they accumulate in "currentBuild" and we cannot find the tests related to the maven execution that just happened.

          FYI the way we retrieve failing tests is:

          {code}
          AbstractTestResultAction testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
          def failedTests = testResultAction.getResult().getFailedTests()
          {code}

          See also https://groups.google.com/forum/?nomobile=true#!topic/jenkinsci-users/dDDPC486JWE

          I've tried to put some logic to save failing tests before and after each maven execution but it cannot work because of "parallel":
          * https://github.com/xwiki/xwiki-jenkins-pipeline/blob/master/vars/xwikiBuild.groovy#L112
          * https://github.com/xwiki/xwiki-jenkins-pipeline/blob/master/vars/xwikiBuild.groovy#L210

          So right now we're stuck and missing a way to get the test result for a single maven execution.

          Thanks
          New: The problem is that our Jenkins file is using parallel() and executes several maven builds (using withMaven).

          We then have some custom logic after each maven execution to analyze failing tests. The problem is that they accumulate in "currentBuild" and we cannot find the tests related to the maven execution that just happened.

          FYI the way we retrieve failing tests is:

          {code}
          AbstractTestResultAction testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
          def failedTests = testResultAction.getResult().getFailedTests()
          {code}

          See also https://groups.google.com/forum/?nomobile=true#!topic/jenkinsci-users/dDDPC486JWE

          I've tried to put some logic to save failing tests before and after each maven execution but it cannot work because of "parallel" (all maven executions starting in parallel save an empty state of failing tests and as soon as one of them gets a failing test, they'll all report it failing and send duplicate emails):
          * https://github.com/xwiki/xwiki-jenkins-pipeline/blob/master/vars/xwikiBuild.groovy#L112
          * https://github.com/xwiki/xwiki-jenkins-pipeline/blob/master/vars/xwikiBuild.groovy#L210

          So right now we're stuck and missing a way to get the test result for a single maven execution.

          Thanks

          Olivier Lamy added a comment -

          I have similar issue.

          The Jenkinsfile is running the same maven project in parallel with jdk8 and jdk9.

          So the results are confusing and no easy way to understand which test has failed with which jdk.

          Could we have more than one TestResultAction per build?

          Ideally I would like to add a label to it.

          ```
          step([$class: 'JUnitResultArchiver', label: somelabel here,
          testResults: '*/target/surefire-reports/TEST-.xml'])
          ```
          WDYT?

          Olivier Lamy added a comment - I have similar issue. The Jenkinsfile is running the same maven project in parallel with jdk8 and jdk9. So the results are confusing and no easy way to understand which test has failed with which jdk. Could we have more than one TestResultAction per build? Ideally I would like to add a label to it. ``` step([$class: 'JUnitResultArchiver', label: somelabel here, testResults: '* /target/surefire-reports/TEST- .xml']) ``` WDYT?
          Oleg Nenashev made changes -
          Component/s New: pipeline-maven-plugin [ 21669 ]
          Component/s Original: core [ 15593 ]
          Component/s Original: maven-plugin [ 16033 ]
          Oleg Nenashev made changes -
          Assignee New: Alvaro Lobato [ alobato ]

          Olivier Lamy added a comment -

          Hi,
          Are you happy with such proposal? I can help with a PR.
          I'm not a cloudbees employee but I can help if you're happy to accept contributions?

          Olivier Lamy added a comment - Hi, Are you happy with such proposal? I can help with a PR. I'm not a cloudbees employee but I can help if you're happy to accept contributions?

          olamy Could you explain how we would get the test results?

          As I mentioned above this is what I'm doing now:

          AbstractTestResultAction testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
          def failedTests = testResultAction.getResult().getFailedTests()
          

          What would be the new way for getting the TestResult/CaseResult objects associated to a single withMaven execution?

          Thanks!

          Vincent Massol added a comment - olamy Could you explain how we would get the test results? As I mentioned above this is what I'm doing now: AbstractTestResultAction testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class) def failedTests = testResultAction.getResult().getFailedTests() What would be the new way for getting the TestResult/CaseResult objects associated to a single withMaven execution? Thanks!

          Olivier Lamy added a comment -

          vmassol we definitely need to keep backward comp here. An idea could be to introduce the label (jdk/os/etc..) at the SuiteResult class level.

          Olivier Lamy added a comment - vmassol we definitely need to keep backward comp here. An idea could be to introduce the label (jdk/os/etc..) at the SuiteResult class level.

          cleclerc alobato WDYT about it ?

          Arnaud Héritier added a comment - cleclerc alobato WDYT about it ?

            Unassigned Unassigned
            vmassol Vincent Massol
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: