CircleCI integration for JUnit XML uploads
The TestNod uploader orb sends your JUnit XML reports to TestNod from a CircleCI workflow. It keeps the change to your config down to a single step, and it handles the upload and finalize flow for you, so there are no API calls to script yourself.
If you haven't created a project yet, the Quickstart walks through that and adding your first upload step. This page picks up from there, covering the orb's parameters along with the patterns for parallel containers, split test suites, and forked pull requests.
Add the project token as a CircleCI context
In CircleCI, open Organization Settings → Contexts, create a context (testnod is a common name), and add an environment variable named TESTNOD_TOKEN with the project token from your project's settings page in TestNod as the value. A context keeps the token in one place and lets you share it across every project that uploads to TestNod, and jobs read it only when you attach the context to them, so it never appears in your config or in job logs.

TESTNOD_TOKEN is the variable name the orb reads by default, so nothing else has to be wired up. If you store the token under a different name, or as a project environment variable instead of a context, pass that name through the token parameter. For more on contexts, see "Using contexts" in CircleCI's documentation.
Add the upload step
Add the orb's upload step after your test step. It 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:
version: 2.1
orbs:
testnod-uploader: testnod/[email protected]
jobs:
test:
docker:
- image: cimg/ruby:3.3
steps:
- checkout
- run:
name: Run tests
command: bundle exec rspec --format progress --format RspecJunitFormatter --out tmp/rspec.xml
- testnod-uploader/upload:
file: tmp/rspec.xml
tags: ci,rspec
ignore_failures: true
workflows:
test-and-upload:
jobs:
- test:
context: testnod
By default the orb uploads the file and finalizes the run in one pass, so a workflow that produces one JUnit XML file needs nothing else. The context: testnod line on the workflow is what puts the token in the job's environment, and without it the token is unset and the upload fails.
Orb parameters
| Parameter | Required | Default | What it does |
|---|---|---|---|
token |
No | TESTNOD_TOKEN |
Name of the environment variable that holds your project token, not the token value. A context variable named TESTNOD_TOKEN needs no override. |
file |
Conditional | "" |
Path to the JUnit XML report. Required unless finalize is only. A path that points to a missing file skips the upload instead of failing the job. |
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 step. |
build_id |
No | $CIRCLE_WORKFLOW_ID |
The identifier that groups uploads into one run. Override it to split runs apart or merge them. |
uploader_version |
No | latest |
Pins the underlying uploader to a specific version instead of tracking the latest release. Pinned versions are cached across runs. |
retry |
No | false |
When true, marks the upload as a rerun of tests that failed earlier in the same build, and tests that pass in it are recorded as passed on retry. Added in orb 1.1 on both the upload command and the standalone job. Works with the default latest uploader, and a pinned uploader_version needs v0.1.0 or later. |
Metadata attached automatically
The orb reads the branch name, commit SHA, and build id from CircleCI's built-in environment variables and builds a link back to the CircleCI job, so you don't pass any of it by hand. The TestNod run page uses that link to point back at the job that produced it. On tag-triggered pipelines, where CircleCI leaves the branch empty, the orb records the tag instead.
Parallel and split builds
CircleCI's parallelism splits one job across several containers, and every container in a workflow shares the same $CIRCLE_WORKFLOW_ID, which the orb uses as the default build_id. Every container that uploads with that build id joins the same TestNod run, which ends up made of one upload per container.
To keep the run open while containers are still reporting, each container uploads with finalize: "false", and a separate job finalizes once with finalize: "only":
version: 2.1
orbs:
testnod-uploader: testnod/[email protected]
jobs:
test:
docker:
- image: cimg/ruby:3.3
parallelism: 4
steps:
- checkout
- run:
name: Run tests
command: |
TESTFILES=$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
bundle exec rspec --format RspecJunitFormatter --out tmp/rspec.xml $TESTFILES
- testnod-uploader/upload:
file: tmp/rspec.xml
tags: ci,rspec
finalize: "false"
workflows:
test-and-upload:
jobs:
- test:
context: testnod
- testnod-uploader/upload:
name: finalize-testnod
context: testnod
finalize: only
requires:
- test
The finalize-testnod job runs the orb's standalone job with finalize: only, and requires: [test] holds it until every container in the test job has finished. It needs the same context so it can read the token to close the run. The same pattern covers fan-out across distinct jobs. For example, if one job runs RSpec and another runs Jest, each uploads its own report with finalize: "false", and a single finalize-only job requires both.
To track a job as its own TestNod run, with separate history and alerts, give it a distinct build_id and keep the default finalize: "true" so it finalizes on its own. For example, build_id: "$CIRCLE_WORKFLOW_ID-rspec" keeps the runs apart, and you can drop the separate finalize job.
Rerun failed tests and upload the retry report
To track tests that pass on a rerun, add a second testnod-uploader/upload step for the rerun report and set retry: true on it. TestNod records those tests as passed on retry and keeps the failure from the first attempt, which is what the flakiness alert counts. Set finalize: "false" on both steps and let the finalize-testnod job from the parallel example close the run:
version: 2.1
orbs:
testnod-uploader: testnod/[email protected]
jobs:
test:
docker:
- image: cimg/ruby:3.3
steps:
- checkout
- run:
name: Run tests
command: bundle exec rspec --format RspecJunitFormatter --out tmp/rspec.xml || true
- run:
name: Rerun failed tests
command: bundle exec rspec --only-failures --format RspecJunitFormatter --out tmp/rspec-retry.xml
- testnod-uploader/upload:
file: tmp/rspec.xml
tags: ci,rspec
finalize: "false"
- testnod-uploader/upload:
file: tmp/rspec-retry.xml
tags: ci,rspec
retry: true
finalize: "false"
workflows:
test-and-upload:
jobs:
- test:
context: testnod
- testnod-uploader/upload:
name: finalize-testnod
context: testnod
finalize: only
requires:
- test
Because the first test command ends in || true, the rerun's exit code decides whether the job passes. If nothing failed, --only-failures writes an empty report and the second upload has no effect. RSpec only reruns failures once config.example_status_persistence_file_path is set, which the Retries and reruns guide covers along with the pytest and Playwright commands.
Forked pull requests
CircleCI does not share contexts or project environment variables with builds triggered by forked pull requests unless you turn on secret passing for forks, which exposes your token to code from outside your organization. Without the token, the upload step has no credentials and fails. Keep the upload out of any workflow that builds forked pull requests, or run those tests in a separate workflow that skips the upload step.
Demo
A complete working example lives at testnod/testnod-circleci-orb-demo. Its .circleci/config.yml runs the test suite from a Ruby on Rails application and uploads the JUnit XML report with the orb, so you can read a full config end to end or fork the repo, drop in your own project token, and watch a run land in TestNod.
What's next
Once the workflow has uploaded a run, open it in TestNod and follow the Test run page tour to see what each part of the page shows. If no run appears or its status looks wrong, check Troubleshooting uploads for the most common causes.