Limiting the retries of builds on non-master branches via code repo

Hello Community,

Problem statement:
When I trigger a build via the code repository and my compute fails for some reason, the build is retried two more times. This happens on non‑master branches.

Is there a solution to limit the number of retries to one for non‑master branches?

So far I found that I can create a schedule on the non‑master branch and then limit retries, but I’m looking for a solution that uses the code repository only (no schedules).