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 aftermain has moved.
Search each branch for:
trunk-io/analytics-uploadertrunk flakytestsortrunk fttrunk-analytics-clirspec_trunk_flaky_tests- The secret that holds your organization token, such as
TRUNK_API_TOKENorTRUNK_TOKEN
Create an API key
- Open API Keys in the Trunk app and click Create Key.
- Name the key after what uses it, such as
flaky-tests-ci. - Select the Upload test results permission.
- 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 asTRUNK_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: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
tokento the API key.@v3fails the step unless the value starts withtrunk_v2_. - Set
test-collection-id. It’s required. If you setTRUNK_TEST_COLLECTION_IDin the environment instead, move it to this input. - Remove
hide-banner,public-repo-idandgh-action-ref.@v3doesn’t have them. For fork pull requests, see Fork pull requests. - Remove
cli-versionif it pins a 0.x release.@v3runs only 1.x. @v3doesn’t readTRUNK_API_TOKENfrom the environment. Pass the key astoken.
Other CI providers
Upload with thetrunk 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
trunkCLI doesn’t update itself in CI. A build image or self-hosted runner with an oldertrunkCLI installed keeps that version. Run the installer in the job, or runtrunk updatewhen you build the image. - If you ran
trunk flakyteststhrough the oldertrunklauncher, the one you installed fromget.trunk.iofor Code Quality, install the newtrunkCLI instead. See Install the trunk CLI. - Remove
TRUNK_ANALYTICS_CLI_VERSIONif it pins a 0.x release. - If you set
TRUNK_API_TOKENor--token, thetrunkCLI 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, orTRUNK_OUTPUT_FORMAT=json, prints the summary as JSON, in the same shape that--summary-output-filewrites.- Test links point at the test in its collection.
- In the JSON summary,
schemaVersionis2, and a failed test’sidis itstestIdin the API. It’snullwhen Trunk couldn’t identify the run’s collection.
Verify the upgrade
- Push the change and let CI run on each branch you changed.
- In the job log, check that the CLI version is 1.0 or later and the upload succeeded.
- 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:- Search every branch again for the old secret’s name.
- Delete the old secret from your CI provider.
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.