--- title: "ADR 0080: /retest and /ok-to-test skip templates that already succeeded" --- * Status: accepted * Code: [`pkg/matcher/annotation_matcher.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/matcher/annotation_matcher.go) (`filterSuccessfulTemplates`, `parseOriginalPRName`, `isSuccessStatus`) ## Context After matching, a `/retest` or `/ok-to-test` comment would restart every matched definition, including ones whose run for the same commit already passed. The matcher has two places to learn about past successes: the PipelineRuns in the repository namespace and the provider commit statuses. Commit statuses are consulted because PipelineRuns may have been pruned. Bitbucket Cloud limits the status key to 40 characters, so its keys can be truncated. ## Decision * The filter only runs for the `retest-all-comment` and `ok-to-test-comment` event types, and returns the input unchanged when the SHA is empty or listing PipelineRuns fails. * PipelineRuns are selected by the SHA label, grouped by the original-PR-name annotation (label as fallback); runs without it are ignored. Only runs with a true `Succeeded` condition count, keeping the newest per template. * Commit statuses with status `success`, `successful` or `completed` (case-insensitive) also mark a template successful, by stripping the `" / "` prefix. Failing to fetch them is logged and does not stop the filter. * For Bitbucket Cloud, when prefix stripping yields nothing, the status key each template would have produced (`GetBBCloudStatusKey`) is compared against the raw successful status keys. * If no non-follow-up match remains, the matcher returns `NoFailedPipelineToRetestError` carrying the gitops comment prefix. ## Consequences * A retest only reruns failed, running or never-run templates. * Matching by template name means two statuses or runs with the same original name are indistinguishable. * Commit-status matching trusts the `AppName / ` convention outside Bitbucket Cloud.