Custom Reporting to Jenkins

12,200

The way Jenkins works is simple: you create a job and Jenkins runs it. Every run of a job is called a build. If you configure the job to look for test report files at the end of a build, the test reports are loaded and presented in the Jenkins UI. There is no way to submit test reports to a build outside of the build or after the build.

Usually this is not a problem. You run your test program/script as part of the build and it produces xml files in the JUnit format. When all the build steps are done, Jenkins looks for the xml files and loads them. You have to tell Jenkins to do it, though. You open the job configuration and you add a new post-build action titled "Publish JUnit test result report". Then you give Jenkins a pattern it uses to search for the files. You can use **/*.xml which means Jenkins will look for all *.xml files in every directory and subdirectory. Or you can e.g. use **/testreports/*.xml if you know where the test reports are going to be.

Share:
12,200
TIMBERings
Author by

TIMBERings

Updated on November 22, 2022

Comments

  • TIMBERings
    TIMBERings 12 months

    I'm trying to hook up our own private testing tool to Jenkins. I'm able to run the test through the command line and create a report on my local machine. I will need to convert that report to xml JUnit format, specifically for Jenkins. Once that is done, how do I associate the xml file that was just created to the most recent job. This way the correct report gets put with the correct job?

  • TIMBERings
    TIMBERings over 11 years
    So if I were to create the report during that job, and point it to the directory that I publish the reports to, how does Jenkins know what report is attached to what job?
  • TIMBERings
    TIMBERings over 11 years
    How do I point the job to the correct report if it's just scanning for *.xml?
  • sti
    sti over 11 years
    All the matching XML files found in the build workspace will belong to that build.
  • Lee Goddard
    Lee Goddard over 10 years
    Jenkins can know which reports to use from an un-wiped workspace by pattern matching Jenkins-specific environment variables that are used to build the path to the report file.
  • Testing Singh
    Testing Singh over 7 years
    This is working for me but I want to publish all XML results in separate graph depending on module?