Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-75534

DiscardOldBranch trait uses AuthorDate of HEAD commit to determine branch age rather than CommitDate

XMLWordPrintable

    • 936.0.0

      When having "Discard branch older than given days" branch filter active, branches which have a HEAD commit that has been first authored a long time ago will be filtered out, even if there are more recent commits on that branch.

      The reason seems to be, that AuthorDate is used to determine age, rather than the more appropriate CommitDate.

      How to reproduce

      Preconditions

      • We assume you have a Bitbucket instance with a repo, that is set up to trigger a Jenkins build on branch push
      • We assume said Jenkins instance is configured to have "Discard branch older than given days" set to any reasonable value, e.g., 30

      Steps

      • Create a branch, add a commit and push it to Bitbucket
      • Wait for the build to start
      • Add a very old commit to the branch by simply git commit -m "Empty" --date "1990-01-01T00:00:00" --allow-empty
      • The resulting PR will have something like (use git log --pretty=fuller to see the details):
        • Author:     *redacted*
          AuthorDate: Mon Jan 1 00:00:00 1990 +0100
          Author:     *redacted*
          CommitDate: Wed Apr 9 15:29:11 2025 +0200
      • Push the branch

      Expected

      Build is triggered

      Actual

      Nothing happens

            nfalco Nikolas Falco
            j_be Juri
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: