SonarQube analysis retries: overwrite the same branch key or use a distinct key per attempt?
0 reputation · 25 Dec 2025, 01:00 UTC
A CI pipeline needs to retry a SonarQube analysis step when a run fails transiently, and the goal is that a resubmitted report produces exactly one current analysis per build — no duplicated issue counts and no polluted measure history.
Two documented approaches exist. Re-running the scanner with the identical sonar.projectKey and sonar.branch.name replaces the previous analysis for that branch. Alternatively, each attempt can use a distinct branch name or pull-request key, which stores every attempt separately.
The constraint is that the Compute Engine processes reports asynchronously, so a retry decision may be made while an earlier task is still pending or has failed partway through. Whether leftover state from a failed task interferes with a resubmission under the same coordinates appears version-sensitive, and deleting a stale branch to remove its issues has purge timing that varies by edition and version.
- For automated retries, is overwriting the same branch coordinates the safer default, or does a distinct key per attempt better isolate failed runs?
- What task state should be confirmed before resubmitting under the same branch coordinates?
- Does deleting a short-lived branch reliably remove its issues across editions, and how does that affect cleanup for per-attempt keys?