[JENKINS-64810] Add creation time boundaries to tags for discovery #1764
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.
[JENKINS-64810] Multibranch pipeline still showing Git tags older than configured threshold
This PR does not address JENKINS-64810 in the way originally expected, because the issue stems from a misunderstanding of the help messages in the
basic-branch-build-strategies-plugin
.The plugin currently describes the time-based tag filtering as:
and
The original issue incorrectly assumed that these settings should remove tag jobs outside the configured time range. However, what the
basic-branch-build-strategies-plugin
actually implements is an extension ofjenkins.branch.BranchBuildStrategy
from thebranch-api-plugin
, which does not have the authority to remove jobs. It simply prevents automatic builds for tags outside the specified time window—which it already does correctly.While it might seem that this issue could be closed based on this clarification, I believe otherwise. After reaching out to the original reporter, Dirk Heinrichs, I found that—despite the misunderstanding of the underlying mechanism—their actual user need remains valid. As the reporter put it:
While this problem shouldn't be addressed by modifying the
basic-branch-build-strategies-plugin
, the user still needs a way to visibly filter old or future tag jobs through the UI.After tracing through the codebase, I found that this functionality could be effectively implemented in the
git-plugin
. In this PR, I introduce two new string parameters—atLeastDays
andatMostDays
—to theTagDiscoveryTrait
class. These parameters mirror the ones from thebasic-branch-build-strategies-plugin
and define the lower and upper bounds for the tag creation time.I then added corresponding logic to
GitSCMSourceContext
to accept and propagate these values (converted intolong
), and finally used them inAbstractGitSCMSource
inside thediscoverTags
function to filter tags based on age:This implementation and its corresponding UI (.jelly definitions) are heavily based on
TagBuildStrategyImpl
from thebasic-branch-build-strategies-plugin
.If this PR is merged, users will be able to use
TagDiscoveryTrait
to filter tag jobs by creation time, thereby fulfilling the practical need described in JENKINS-64810—even though the original interpretation of the issue was flawed.Please also let me know if there’s anything I should revise or improve. Thank you for your time and guidance!
Testing done
None yet.
I could use some help here, as I'm unsure how to add proper tests for this change in
AbstractGitSCMSourceTest
.I've installed it on my local Jenkins instance, and it works well with my git tags.
Submitter checklist