Documentation

GitLab CI/CD integration for JUnit XML uploads

The TestNod uploader component sends your JUnit XML reports to TestNod from a GitLab CI/CD pipeline. You add it to your pipeline with a single include, and it runs the upload and finalize flow itself, so you don't have to script any API calls.

If you don't have a project yet, start with the Quickstart, which covers creating one and adding a first upload step. The sections below cover the component's inputs and the patterns for parallel jobs, matrix builds, and merge requests from forks.

Add the project token as a CI/CD variable

In GitLab, open your project's Settings → CI/CD → Variables and add a variable named TESTNOD_TOKEN with the project token from your project's settings page in TestNod as the value. Mark it as Masked so it never shows up in job logs. The component reads TESTNOD_TOKEN by default, so that name needs no extra configuration. If you store the token under a different name, pass that name through the token-variable input.

GitLab project CI/CD settings page showing the new TESTNOD_TOKEN variable marked as Masked

For more on CI/CD variables, see "CI/CD variables" in GitLab's documentation.

Add the upload step

Pull the component in with an include block and expose your JUnit report as a job artifact. The component adds one job to your pipeline that runs in the .post stage by default, so it comes after every other job. That job runs with when: always built in, so results upload on both passing and failing runs.

The following config runs RSpec and uploads the JUnit XML report to TestNod:

include:
  - component: gitlab.com/testnod/testnod-uploader/[email protected]
    inputs:
      file: tmp/rspec.xml
      tags: ci,rspec
      ignore-failures: true

rspec:
  stage: test
  image: ruby:3.3
  script:
    - bundle exec rspec --format progress --format RspecJunitFormatter --out tmp/rspec.xml
  artifacts:
    when: always
    paths:
      - tmp/rspec.xml

Version 2 of the component needs GitLab 18.10 and GitLab Runner 17.3 or later. A self-managed instance on an older GitLab can stay on [email protected], which has every input on this page except retry and cache-policy.

Because the upload job runs in the .post stage, it automatically picks up the artifacts your test jobs produced, so artifacts: when: always on the test job is what keeps the report available even when the tests fail. By default the component uploads the file and finalizes the run in one pass, so that single include covers the whole upload for a pipeline that produces one JUnit XML file.

Component inputs

Input Required Default What it does
token-variable No TESTNOD_TOKEN Name of the CI/CD variable that holds your project token, not the token value. A variable named TESTNOD_TOKEN needs no override.
file Conditional "" Path or glob of the JUnit XML report(s). Required unless finalize is only.
tags No "" Comma-separated tags applied to the run. Tags group runs in the dashboard and scope TestNod's analysis to comparable runs.
finalize No "true" "true" uploads the file and finalizes the run, "false" uploads without closing the run, and only finalizes without uploading.
ignore-failures No false When true, an upload or finalize error logs a warning instead of failing the job.
build-id No $CI_PIPELINE_ID The identifier that groups uploads into one run. Override it to split runs apart or merge them.
job-name No testnod-upload Name of the job the component adds to your pipeline. Override it when you include the component more than once so the jobs don't collide.
stage No .post Stage the upload job runs in. The default .post stage runs after every other stage.
image No curlimages/curl:8.22.0 Container image for the upload job. Any image with curl and a POSIX shell works.
uploader-version No latest Pins the underlying uploader to a specific version. The default latest re-downloads it on every run.
cache-policy No pull for latest, otherwise pull-push How the job caches the uploader binary. You rarely need to set it.
retry No false When true, marks the uploaded report as a rerun of tests that failed earlier in the same build, and tests that pass in it are recorded as passed on retry. Works with the default latest uploader. With a pinned uploader-version older than v0.1.0, the job fails instead of uploading.

Metadata attached automatically

The component reads the branch name, commit SHA, and build ID from GitLab's predefined variables, so you don't pass any of them by hand. It also builds a link back to the pipeline, which the TestNod run page uses to point at the pipeline that produced the run.

Parallel and matrix builds

GitLab's parallel keyword splits one job across several instances, and a matrix build runs the same job across several variable combinations. Every job in the pipeline shares the same $CI_PIPELINE_ID, which the component uses as the default build-id, so their reports all belong to the same TestNod run, which ends up made of one upload per report.

Have each instance write its report to a distinct filename, expose them all as artifacts, and point the component's file input at a glob. The single upload job in the .post stage collects every matching report and finalizes the run once:

include:
  - component: gitlab.com/testnod/testnod-uploader/[email protected]
    inputs:
      file: tmp/rspec-*.xml
      tags: ci,rspec
      ignore-failures: true

rspec:
  stage: test
  image: ruby:3.3
  parallel: 3
  script:
    - bundle exec rspec --format RspecJunitFormatter --out "tmp/rspec-${CI_NODE_INDEX}.xml"
  artifacts:
    when: always
    paths:
      - tmp/rspec-*.xml

To fan out across distinct suites, give each its own upload with finalize: "false" and close the run once with a finalize: "only" include, setting a distinct job-name on each so the injected jobs don't collide. For example, with one job running RSpec and another running Jest:

include:
  - component: gitlab.com/testnod/testnod-uploader/[email protected]
    inputs:
      job-name: testnod-upload-rspec
      file: tmp/rspec.xml
      tags: ci,rspec
      finalize: "false"
  - component: gitlab.com/testnod/testnod-uploader/[email protected]
    inputs:
      job-name: testnod-upload-jest
      file: tmp/jest.xml
      tags: ci,jest
      finalize: "false"
  - component: gitlab.com/testnod/testnod-uploader/[email protected]
    inputs:
      job-name: testnod-finalize
      finalize: "only"

A suite can also be its own TestNod run, with separate history and alerts. Give it a distinct build-id, such as build-id: $CI_PIPELINE_ID-rspec, and leave finalize at its default "true" so it closes the run on its own without the separate finalize job. Each of those runs counts toward your organization's monthly test runs.

Rerun failed tests and upload the retry report

To track tests that pass on a rerun, include the component a second time for the rerun report with retry: true. TestNod records those tests as passed on retry and keeps the failure from the first attempt, which is what the flakiness alert counts. Each include needs its own job-name. Both uploads set finalize: "false", and a third include closes the run:

include:
  - component: gitlab.com/testnod/testnod-uploader/[email protected]
    inputs:
      job-name: testnod-upload
      file: tmp/rspec.xml
      tags: ci,rspec
      finalize: "false"
  - component: gitlab.com/testnod/testnod-uploader/[email protected]
    inputs:
      job-name: testnod-upload-rerun
      file: tmp/rspec-retry.xml
      tags: ci,rspec
      retry: true
      finalize: "false"
  - component: gitlab.com/testnod/testnod-uploader/[email protected]
    inputs:
      job-name: testnod-finalize
      finalize: "only"

rspec:
  stage: test
  image: ruby:3.3
  script:
    - bundle exec rspec --format RspecJunitFormatter --out tmp/rspec.xml || true
    - bundle exec rspec --only-failures --format RspecJunitFormatter --out tmp/rspec-retry.xml
  artifacts:
    when: always
    paths:
      - tmp/rspec.xml
      - tmp/rspec-retry.xml

With || true on the first test command, the job's result comes from the rerun. When nothing failed, --only-failures writes an empty report and the rerun upload has no effect. The Retries and reruns guide explains the config.example_status_persistence_file_path setting RSpec needs for --only-failures, and it shows the pytest and Playwright commands.

Protected variables and forks

GitLab only injects Protected variables into pipelines running on protected branches and tags. If you mark TESTNOD_TOKEN as Protected, pipelines from forks or unprotected feature branches won't receive it, so the component has no token and the upload fails. With ignore-failures: true the job logs a warning instead of failing the pipeline, but no run reaches TestNod. Leave the variable unprotected to report from every branch, or keep it protected and accept that only protected branches reach TestNod.

Demo

A complete working example lives at testnod/testnod-gitlab-demo. Its .gitlab-ci.yml runs the test suite from a Ruby on Rails application and exposes the JUnit XML report as an artifact for the component to upload, so you can read a full pipeline end to end, or fork the repo and add your own project token to send a run to TestNod.

What's next

Run the pipeline, then open the new run in your TestNod project. The Test run page tour explains what each part of its page shows, and if the run doesn't show up or its status looks wrong, Troubleshooting uploads lists the most common causes.

Start tracking your test runs

The Solo plan is free for one project and 250 test runs a month, and you don't need a credit card to sign up.

Sign up free