4
votes

The question may sound silly, but I haven't found how to configure the XML report path in the Post-build Junit task after an hour of manipulations. I generate the JUnit test report (the XML file) here :

C:\Program Files\Jenkins\jobs\UPWSP\workspace\up\UPWSP\current\06-Java Unit Testing\junit\TESTS-TestSuites.xml

And the job using the XML has its worskpace at this path :

C:\Program Files\Jenkins\jobs\UPWSP - Tests JUnit\workspace\

The JUnit report post-build task seems to take only relatives path and I already tried with

../../UPWSP/up/UPWSP/current/06-Java Unit Testing/junit/TESTS-TestSuites.xml

**../../UPWSP/up/UPWSP/current/06-Java Unit Testing/junit/TESTS-TestSuites.xml

It always tells me '..' is not a valid path, and an absolute path won't work either. Any idea of how I should use it?

6

6 Answers

12
votes

AFAIK, the path for the JUnit XML file has to be a sub-directory of your project. It should not be outside the job's workspace. Once you have created a directory inside workspace, say for example, junit-test, then the following should work as expected when specified in Test report XMLs section: junit-test\TESTS-TestSuites.xml

5
votes

You can use wildcards like **/target/surefire-reports/*.xml or, in your case, **/junit/*.xml

3
votes

This is a work around and not an actual answer. I had to copy the xml to the job directory with a xcopy command line. My job is now working, but that's not how I expected things to work

1
votes

Try putting this in the "Test report XMLs" field (assuming you are on windows machine):

up\UPWSP\current\06-Java Unit Testing\junit\*.xml

I am not clear about "job using the XML" part you detailed. How is that related to the job generating the junit reports?

0
votes

You have to put junit step into dir step like this:

pipeline{
  stages{
    stage("Run tests")
      steps{
        echo "Here generate some test_result.xml files in /some/path"
      }
  }
  post {
    success {
      dir('/some/path')
      {
        junit '**/test_result.xml'
      }
    }
}

}

0
votes

On windows, use explorer and go to your installation directory. Something like this C:\Users\me\.jenkins\workspace\PetClinic\target. Add a new folder. Go back to Jenkins dashboard. If you see a red x in post-build actions, click it. Reselect the options and add the new path **/target/newfolder/*.xml. edit: Find the folder that has the tests in it from the cloned repo. Use that folder, in my case it is surefire-reports