Allow re-run failed tests to be triggered via API
F
Fabio Leandro
Currently this is only available via the GUI.
This feature request is to introduce this functionality to users via a CircleCI API endpoint
Minjun Seong
Hi everyone! To reduce friction of the current "re-run failed test" experience, we are looking into the ability to automatically re-running failed tests. You can set a "max # of auto reruns of failed tests" in the config. Let us know if a solution like this would solve your painpoint!
Question: We are evaluating the need for a "delay" between auto reruns. Would you mind elaborating on why or why not a delay would be necessary?
Ashley Lake
Minjun Seong A delay just long enough for someone to inspect the tests and see if they're flaky or legitimate seems plausible to me. I suspect my company would use it, especially after 2 failures.
Minjun Seong
Ashley Lake: The goal of the delay is to allows temporary issues like external service interruptions or resource contentions to resolve naturally, preventing all retry attempts from failing against the same transient problem.
Would you mind sharing why you'd need to inspect the test before the auto-retry rather than just letting the retry happen automatically?
Ashley Lake
Minjun Seong See my previous answer: "for someone to inspect the tests and see if [the failures are] flaky or legitimate"
E
Eryn Cantrell
Minjun Seong For us, the first motivation has to do with the fact that there is no button on the overall workflows screen (which is most heavily used by our devs) that lets you re-run only failed tests if you have set that up on any job in a workflow. (See the screenshot attached.) Also, we sometimes make internal tools to make our processes faster, and would love to have this available via API. It's a really valuable feature that is hidden away.
Minjun Seong
Eryn Cantrell: Appreciate the quick reply! Could you tell me more about the internal tools (what does it do and what is the current limitation?) and how you see it using the re-run failed tests API?
E
Eryn Cantrell
Minjun Seong For sure, last we checked there wasn't an iOS or MacOS app for CircleCi, so some of our mobile devs made an internal-use tool for our workflows that can be run easily on the phone or mac and using the CircleCI API since that was faster than using the browser UI for them.
Minjun Seong
Hi folks, I'm a product manager at CircleCI. I'd love to understand the problem you're trying to solve a bit better. What's the motivation for wanting to re-run failed tests via API?
Thank you!
Nick Chursin
Minjun Seong, the motivation is to rerun failed tests only for the workflow, not the whole job. There's already option to do this on UI
Ashley Lake
Minjun Seong we'd like to automatically retry tests that are likely to be flaky, because it's more expensive to spend human labor detecting the failure, visiting your website, and clicking the dropdown, than it is to have a retry of _only the specific failing tests_ occur automatically based on automation we set up on our end.
Jeremy
Minjun Seong With our development, we have a large number of tests that run, and some are flaky. We do need to improve our tests, but being able to re-run failed tests automatically for the first x times would mean that whenever manual intervention is required, we know it is actually needed.
We can already retry the entire tests job, but since we have so many tests, it would be a waste to rerun all of the other tests that have already passed. This was our first solution.
L
Laura McRae
Minjun Seong We're dealing with a similar issue - we have flaky tests that fail intermittently, and the current auto-rerun option restarts the entire workflow/step instead of just the failed tests. This wastes a lot of CI time and credits.
Our ideal workflow would be:
- Build runs with 100 tests
- 5 tests fail due to flakiness
- API call to re-run just those 5 failed tests
- Get results without re-running the 95 that already passed
Right now we either have to manually click through the UI to re-run individual tests, or use auto-rerun which restarts everything from scratch. For large test suites, that's a huge time and cost multiplier.
Being able to programmatically re-run just the failed tests would let us build smarter automation around handling flaky tests without burning through our CI budget.
Minjun Seong
Laura McRae: Would you mind elaborating on what is limiting with your experience of having to "manually click through the UI to re-run individual tests"?
Just wanted to confirm as if you are referring to the "re-run failed tests" feature (https://circleci.com/docs/guides/test/rerun-failed-tests/), you shouldn't need to click through individual test, it should rerun all failed tests.
Minjun Seong
Nick Chursin To confirm, are you saying that you want to be able to re-run failed tests across multiple test jobs within the workflow?
Nick Chursin
Minjun Seong yes. Now doing this manually with UI
Ashley Lake
Enabling this feature would save our company significantly.
Nick Chursin
Hello from 2025 👋
How’s that in the future?
Adebayo Makanjuola
Hi, any update on this?