Bug Description
The /retest command was fixed in PR #2048 (commit cd437c52a) to skip already-green pipelines (SRVKP-7236). However, this fix only works when the original PipelineRun objects still exist in the Kubernetes cluster.
When PipelineRuns are pruned — either by max-keep-runs or by Tekton Results pruner — /retest silently falls back to re-running all pipelines, defeating the purpose of the fix.
Steps to Reproduce
- Configure a repository with multiple pipelines (e.g.,
lint, test, build)
- Push a commit — all three pipelines run,
lint and build succeed, test fails
- Wait for PipelineRuns to be pruned (via
max-keep-runs or Tekton Results pruner)
- Comment
/retest on the PR
- Expected: Only
test is re-run (since lint and build succeeded)
- Actual: All three pipelines are re-run
Root Cause
In pkg/matcher/annotation_matcher.go:441-498, filterSuccessfulTemplates():
- Queries Kubernetes for PipelineRuns matching the SHA label (lines 447-450)
- When the query succeeds but returns 0 results (PipelineRuns pruned), the
successfulTemplates map is empty
- All templates pass through the filter → all pipelines re-run
- There is no fallback to check
Repository.Status (which persists after pruning)
Possible Solution Direction
Use Repository.Status as a fallback when no PipelineRuns are found in the cluster. This would require:
- Adding an
OriginalPRName field (template name) to RepositoryRunStatus (pkg/apis/pipelinesascode/v1alpha1/types.go:28) so that status entries can be matched back to pipeline templates
- Updating
filterSuccessfulTemplates() to consult Repository.Status when the Kubernetes PipelineRun query returns empty results
Note: RepositoryRunStatus is currently limited to 5 entries (maxPipelineRunStatusRun in pkg/reconciler/status.go:28), which may need consideration depending on the number of pipelines configured.
Additional Context