• Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • Jenkins 2.303.1
      Enhanced Old Build Discarder plugin 1.4

      When setting 

      buildDiscarder([$class: 'EnhancedOldBuildDiscarder', artifactDaysToKeepStr: '',
                                                           artifactNumToKeepStr: '',
                                                           daysToKeepStr: '7',
                                                           numToKeepStr: '',
                                                           discardOnlyOnSuccess: false,
                                                           holdMaxBuilds: false]),
      

      in properties, the build is not removed after 7 days if there is only one build remaining.
      The documentation for "Days to keep builds" states:

      if not empty, build records are only kept up to this number of days
      

      so I would assume that the build should be discarded even if it is the last remaining build.

          [JENKINS-66572] Last remaining build is not discarded

          Christoph Vogtländer created issue -
          Christoph Vogtländer made changes -
          Description Original: When setting 
          {code:java}
          buildDiscarder([$class: 'EnhancedOldBuildDiscarder', artifactDaysToKeepStr: '',
                                                               artifactNumToKeepStr: '',
                                                               daysToKeepStr: 7,
                                                               numToKeepStr: '',
                                                               discardOnlyOnSuccess: false,
                                                               holdMaxBuilds: false]),
          {code}
          in _properties_, the build is not removed after 7 days if there is only one build remaining.
           The documentation for "Days to keep builds" states:
          {noformat}
          if not empty, build records are only kept up to this number of days
          {noformat}
          so I would assume that the build should be discarded even if it is the last remaining build.
          New: When setting 
          {code:java}
          buildDiscarder([$class: 'EnhancedOldBuildDiscarder', artifactDaysToKeepStr: '',
                                                               artifactNumToKeepStr: '',
                                                               daysToKeepStr: '7',
                                                               numToKeepStr: '',
                                                               discardOnlyOnSuccess: false,
                                                               holdMaxBuilds: false]),
          {code}
          in _properties_, the build is not removed after 7 days if there is only one build remaining.
           The documentation for "Days to keep builds" states:
          {noformat}
          if not empty, build records are only kept up to this number of days
          {noformat}
          so I would assume that the build should be discarded even if it is the last remaining build.

          Christoph Vogtländer added a comment - - edited

          I also tried

          buildDiscarder([$class: 'EnhancedOldBuildDiscarder', artifactDaysToKeepStr: '',
                                                               artifactNumToKeepStr: '',
                                                               daysToKeepStr: '1',
                                                               numToKeepStr: '0',
                                                               discardOnlyOnSuccess: false,
                                                               holdMaxBuilds: true]),

          The help explicitly states:

          Setting Max # of builds to keep to 0 causes any build exceeding the age limit to be discarded.

          But the latest build will still remain.

          Christoph Vogtländer added a comment - - edited I also tried buildDiscarder([$class: 'EnhancedOldBuildDiscarder' , artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '1' , numToKeepStr: '0' , discardOnlyOnSuccess: false , holdMaxBuilds: true ]), The help explicitly states: Setting Max # of builds to keep to 0 causes any build exceeding the age limit to be discarded. But the latest build will still remain.

          In the Jenkins log there is an entry:

          job #2 is not to be removed or purged of artifacts because it’s the last successful build

          Christoph Vogtländer added a comment - In the Jenkins log there is an entry: job #2 is not to be removed or purged of artifacts because it’s the last successful build

            Unassigned Unassigned
            gordin Christoph Vogtländer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: