Skip to main content
The Trunk Analytics CLI 1.0 uploads only to test collections and accepts only an API key. Upgrading means three changes for each upload: an API key in place of the organization token, a test collection ID, and no removed flags. 0.17.x keeps working with the organization token until December 31, 2027. It gets important fixes, but no new features.
The credential and the CLI version change together. 0.17.x refuses an API key, and 1.0 refuses the organization token. Changing only one of them stops your uploads.

Before you start

Find every place that uploads

Check every branch that runs CI, not only your default branch. That includes release branches, maintenance branches and long-lived feature branches. A branch keeps the CI files it was created with, so an old release branch can still run an old uploader with the organization token after main has moved. Search each branch for:
  • trunk-io/analytics-uploader
  • trunk flakytests or trunk ft
  • trunk-analytics-cli
  • rspec_trunk_flaky_tests
  • The secret that holds your organization token, such as TRUNK_API_TOKEN or TRUNK_TOKEN
For example:
Also check CI configuration that isn’t in the repository, such as shared GitHub Actions workflows, reusable CircleCI orbs, Buildkite pipeline settings, and Jenkins shared libraries.

Create an API key

  1. Open API Keys in the Trunk app and click Create Key.
  2. Name the key after what uses it, such as flaky-tests-ci.
  3. Select the Upload test results permission.
  4. Copy the key. It starts with trunk_v2_ and is shown only once.

Store it under a new secret name

Add the API key to your CI provider as a new secret, such as TRUNK_API_KEY. Don’t overwrite the secret that holds your organization token. Every branch that hasn’t moved yet still runs 0.17.x or earlier with the old secret. If you overwrite that secret with the API key, those branches get a key they refuse, and their uploads stop. With two secrets, each branch keeps working until you upgrade it.

Find your test collection ID

Each upload names the test collection it goes to. If your repository uploaded before test collections, Trunk already created a collection for it, and its test history is there. Open Flaky Tests → Collections in the Trunk app, open the collection, and copy its Collection ID from the page header. The ID isn’t a secret, so you can write it in your CI configuration. You can also list your collections with the API. Any API key can call it, including the one you just created:
Each collection’s id is its Collection ID, a short value such as aB3xY9kQ. Pass it as the test collection ID. See List test collections. To create a collection, see Getting Started.

Upgrade your uploads

Follow the section for each setup you found. Change the credential and the version in the same commit.

GitHub Actions

trunk-io/analytics-uploader@v2 stays on 0.17.x. Move every step to @v3, which runs 1.0:
  • Set token to the API key. @v3 fails the step unless the value starts with trunk_v2_.
  • Set test-collection-id. It’s required. If you set TRUNK_TEST_COLLECTION_ID in the environment instead, move it to this input.
  • Remove hide-banner, public-repo-id and gh-action-ref. @v3 doesn’t have them. For fork pull requests, see Fork pull requests.
  • Remove cli-version if it pins a 0.x release. @v3 runs only 1.x.
  • @v3 doesn’t read TRUNK_API_TOKEN from the environment. Pass the key as token.
Every other input is unchanged. See GitHub Actions.

Other CI providers

Upload with the trunk CLI. Install it fresh in each job, so the job gets trunk CLI 0.0.14 or later, which runs Analytics CLI 1.0:
  • The trunk CLI doesn’t update itself in CI. A build image or self-hosted runner with an older trunk CLI installed keeps that version. Run the installer in the job, or run trunk update when you build the image.
  • If you ran trunk flakytests through the older trunk launcher, the one you installed from get.trunk.io for Code Quality, install the new trunk CLI instead. See Install the trunk CLI.
  • Remove TRUNK_ANALYTICS_CLI_VERSION if it pins a 0.x release.
  • If you set TRUNK_API_TOKEN or --token, the trunk CLI passes it instead of the stored key. Set it to the API key, or remove it.

RSpec plugin

rspec_trunk_flaky_tests 1.0 is already the latest version on RubyGems, so an unpinned gem, or a Dependabot or Renovate update, installs it now. The 1.0 gem requires these environment variables when you run rspec. If one is missing, or TRUNK_API_TOKEN holds the organization token, the run fails before any test runs. To run without Trunk, set DISABLE_RSPEC_TRUNK_FLAKY_TESTS=true. An empty TRUNK_API_TOKEN, such as on a fork pull request with no secrets, turns the gem off without failing. If you aren’t ready to move, pin 0.17.x:

What changes in 1.0

Removed flags and variables

upload and validate exit with code 2 on a removed flag. trunk flakytests test reads an unknown flag before -- as part of your test command, so the run fails and your tests don’t run.

Fork pull requests

--allow-forked-pr-uploads (allow-forked-pr-uploads: true on @v3) uploads with no API key, but only in a GitHub Actions run of a pull request from a fork, with GITHUB_TOKEN in the job’s environment. Anywhere else it uploads nothing and says why. See Fork PR uploads.

Output

  • The summary goes to stdout. Logs, notices and progress go to stderr. A script that reads only stderr loses the summary.
  • --output-format json, or TRUNK_OUTPUT_FORMAT=json, prints the summary as JSON, in the same shape that --summary-output-file writes.
  • Test links point at the test in its collection.
  • In the JSON summary, schemaVersion is 2, and a failed test’s id is its testId in the API. It’s null when Trunk couldn’t identify the run’s collection.

Verify the upgrade

  1. Push the change and let CI run on each branch you changed.
  2. In the job log, check that the CLI version is 1.0 or later and the upload succeeded.
  3. Open the collection’s Uploads tab in the Trunk app and check that uploads arrive from each branch and CI job.

Retire the organization token

Keep the old secret until no branch uses it. When every branch you still run CI on has moved:
  1. Search every branch again for the old secret’s name.
  2. Delete the old secret from your CI provider.
Branches you never build again can keep the old configuration. If you build one later, its upload fails. The organization token is still used by other Trunk features, such as the legacy API and Merge Queue. Don’t rotate or revoke it unless nothing else uses it.

Troubleshooting

Staying on 0.17.x for now

To keep the organization token until you move, pin 0.17.x everywhere you upload: The trunk CLI passes a stored API key only to 1.0 and later, so a pinned 0.17.x needs the organization token in TRUNK_API_TOKEN.