[JENKINS-60730] Add stale branch, tag, and pull request filter traits - #1558
Open
cdarninsuang-bamfunds wants to merge 1 commit into
Open
[JENKINS-60730] Add stale branch, tag, and pull request filter traits#1558cdarninsuang-bamfunds wants to merge 1 commit into
cdarninsuang-bamfunds wants to merge 1 commit into
Conversation
cdarninsuang-bamfunds
force-pushed
the
stale-scm-filter-traits
branch
2 times, most recently
from
August 25, 2026 12:19
2577fab to
7cbef3f
Compare
Add three SCMSourceTrait extensions that exclude stale heads from GitHub multibranch/org-folder indexing: - StaleBranchFilterTrait: filter branches with no commits in N days - StaleTagFilterTrait: filter tags older than N days - StalePullRequestFilterTrait: filter PRs with no activity in N days Each trait supports an optional include/exclude regex to scope or exempt heads by name, and a dry-run mode that logs what would be filtered without excluding it. StaleBranchFilterTrait never filters the default branch or a GitHub-protected branch, regardless of age. Includes unit tests for each trait. See JENKINS-60730 and jenkinsci#263 for prior discussion of this feature.
cdarninsuang-bamfunds
force-pushed
the
stale-scm-filter-traits
branch
from
August 25, 2026 12:23
7cbef3f to
b7cd7e6
Compare
Member
|
Briefly: no, this is handled by separate plugins. |
Author
|
Would you reconsider? For our teams the operational cost of an extra plugin — another artifact to install, trust, security-scan, and keep in lockstep across controllers — is real, and JENKINS-60730 suggests this is a first-class need for this plugin's users. This PR also adds include/exclude regex scoping, a dry-run preview, and a default/protected-branch guard that the separate plugin doesn't have. Happy to iterate on the approach if the discovery-filter mechanism is the sticking point. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
See JENKINS-60730 for background — a previous attempt at this landed as #263 in 2020 and was closed in favor of installing scm-filter-aged-refs-plugin. I'd like to make the case for revisiting that, and to be upfront about the one open design question from #263 that still applies here.
What this adds: three opt-in
SCMSourceTraits that exclude stale heads from GitHub multibranch/org-folder indexing:StaleBranchFilterTrait— branches with no commits in the last N daysStaleTagFilterTrait— tags older than N daysStalePullRequestFilterTrait— PRs with no activity (commits/comments/reviews/labels) in the last N daysEach supports an include/exclude regex to scope filtering by head name, and a dry-run mode that logs what would be filtered without excluding it.
StaleBranchFilterTraitadditionally never filters the repository's default branch or a GitHub-protected branch, regardless of age.Why here instead of the separate plugin: the underlying problem (JENKINS-60730) is unwanted mass rebuild/indexing load from stale refs — a first-class concern for this plugin's users, not a niche one. Filtering lives alongside every other "Behaviours" option users already configure, rather than requiring a second plugin install. Compared to
scm-filter-aged-refs-plugin, this adds include/exclude regex scoping, a dry-run preview, and a protected/default-branch guard — none of which that plugin currently has.The open design question from #263: bitwiseman's core objection to the 2020 PR wasn't just "use the other plugin" — it was that an
SCMHeadFilter-based discovery trait makes stale heads disappear entirely (job node removed), rather than just skipping their builds via aBranchBuildStrategy(asChangeRequestBuildStrategyImpldoes). This PR uses the same discovery-filter mechanism as #263, for the same reason it did: tags and pull requests have noBranchBuildStrategy-equivalent hook, only branches do, soSCMHeadFilteris the only mechanism that covers all three ref types uniformly. I've tried to make that discovery-time removal as safe as reasonably possible — dry-run to preview impact before enabling, and default/protected branches are never filtered regardless of age — but I'd rather flag this trade-off explicitly than leave it for review to rediscover.Submitter checklist
Manual test instructions
Reviewer checklist
Documentation changes
No separate jenkins.io doc changes proposed; each trait ships inline
help.htmldescribing its behaviour, consistent with the plugin's existing traits.Users/aliases to notify
@bitwiseman — you reviewed #263 / JENKINS-60730 in 2020; tagging you given the history, and because I've tried to directly address the discovery-vs-build-strategy trade-off you raised then.