Search code examples
testinggitlabreport

GitLab API get test report


I save test report (jUnit) in job artifacts:

    artifacts:
        when: always
        name: Syntax
        expire_in: 1 week
        reports:
            junit: junit.xml

I have a report in pipeline:

Pipeline download

How I can download this report by GilLab API?

I try https://docs.gitlab.com/ee/api/job_artifacts.html#get-job-artifacts, but it not return reports.


Solution

  • It doesn't look like the API currently supports retrieving Report Artifacts, but you can make a small change to your pipeline that will allow you to download them as generic Artifacts.

    You can upload multiple types of artifacts in a single job, and can even upload the same file as both a report artifact and a generic one:

    artifacts:
      when: always
      name: Syntax
      expire_in: 1 week
      reports:
        junit: junit.xml
      paths:
        - junit.xml
    

    Uploading the artifact using the paths keyword will allow you to download the file via the Get Job Artifacts API, and will still allow the report artifact to be parsed and displayed on the Merge Request tests widget.