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

The 'Discard Old Builds' advanced option - removal of only artifacts - does not work for me after 1.503.

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • Fedora 18 x86_64

      Activating the 'Discard Old Builds' checkbox on a job allows an Advanced option to specify 'Max # of builds to keep with artifacts'.
      This does not seem to clean up the artifacts for my builds anymore.
      I have tested 1.502, 1.503, 1.504 up to 1.510. It works fine in 1.502 but in none of the later versions.

      The artifacts I refer to are archived with the default archiving mechanism (not the archiving that can be configured as a post-step).

          [JENKINS-17508] The 'Discard Old Builds' advanced option - removal of only artifacts - does not work for me after 1.503.

          Per J. Lund created issue -

          Per J. Lund added a comment -

          I have investigated this problem further and found the following:

          I have added some log to the LogRotator.java in both 1.502 and 1.510 - in the 'perform' method:
          Added print-out of artifactsDir in the loop below:

          if(artifactNumToKeep!=null && artifactNumToKeep!=-1) {
          List<? extends Run<?,?>> builds = job.getBuilds();
          for (Run r : copy(builds.subList(Math.min(builds.size(), artifactNumToKeep), builds.size()))) {
          LOGGER.log(INFO, "artifactsDir =

          {0}

          ", r.getArtifactsDir());

          The log seen in version 1.502 is e.g:
          INFO: artifactsDir = /var/lib/jenkins/jobs/PJLTEST/modules/com.corena.core$repository-management/builds/2013-04-08_20-28-13/archive

          while in 1.510 it is e.g.:
          INFO: artifactsDir = /var/lib/jenkins/jobs/PJLTEST/builds/2013-04-08_20-29-49/archive

          This shows that it is a completely different behaviour between the two version and now artifacts will be removed as the directory seen in 1.510 does not even exist.

          Per J. Lund added a comment - I have investigated this problem further and found the following: I have added some log to the LogRotator.java in both 1.502 and 1.510 - in the 'perform' method: Added print-out of artifactsDir in the loop below: if(artifactNumToKeep!=null && artifactNumToKeep!=-1) { List<? extends Run<?,?>> builds = job.getBuilds(); for (Run r : copy(builds.subList(Math.min(builds.size(), artifactNumToKeep), builds.size()))) { LOGGER.log(INFO, "artifactsDir = {0} ", r.getArtifactsDir()); The log seen in version 1.502 is e.g: INFO: artifactsDir = /var/lib/jenkins/jobs/PJLTEST/modules/com.corena.core$repository-management/builds/2013-04-08_20-28-13/archive while in 1.510 it is e.g.: INFO: artifactsDir = /var/lib/jenkins/jobs/PJLTEST/builds/2013-04-08_20-29-49/archive This shows that it is a completely different behaviour between the two version and now artifacts will be removed as the directory seen in 1.510 does not even exist.
          Per J. Lund made changes -
          Assignee Original: vjuranek [ vjuranek ] New: Kohsuke Kawaguchi [ kktest3 ]
          Per J. Lund made changes -
          Component/s New: core [ 15593 ]
          Component/s Original: disk-usage [ 15537 ]
          Geoff Cummings made changes -
          Link New: This issue is related to JENKINS-17355 [ JENKINS-17355 ]

          Wondering if it's related to this change:

          What's new in 1.503 (2013/02/26)

          • "Discard old build records" behavior is now pluggable, allowing plugins to define custom logic.

          Geoff Cummings added a comment - Wondering if it's related to this change: What's new in 1.503 (2013/02/26) "Discard old build records" behavior is now pluggable, allowing plugins to define custom logic.

          Per J. Lund added a comment -

          Yes, it is related to that change.
          Unfortunately I don't have the insight to fix the problem, because it is causing us full disks...

          Per J. Lund added a comment - Yes, it is related to that change. Unfortunately I don't have the insight to fix the problem, because it is causing us full disks...

          Balder VC added a comment -

          It seems to me that each of the modules have their own configuration file. But the tag e.g.
          <logRotator class="hudson.tasks.LogRotator">
          <daysToKeep>-1</daysToKeep>
          <numToKeep>50</numToKeep>
          <artifactDaysToKeep>-1</artifactDaysToKeep>
          <artifactNumToKeep>2</artifactNumToKeep>
          </logRotator>
          that enables the cleanup is not propagated to these build modules configuration files. It is in the master configuration file of the job though. I think if you add logRotator to the modules config.xml they will be cleaned. I'll add it to some jobs on our Jenkins on Monday to see if that is the case.

          Balder VC added a comment - It seems to me that each of the modules have their own configuration file. But the tag e.g. <logRotator class="hudson.tasks.LogRotator"> <daysToKeep>-1</daysToKeep> <numToKeep>50</numToKeep> <artifactDaysToKeep>-1</artifactDaysToKeep> <artifactNumToKeep>2</artifactNumToKeep> </logRotator> that enables the cleanup is not propagated to these build modules configuration files. It is in the master configuration file of the job though. I think if you add logRotator to the modules config.xml they will be cleaned. I'll add it to some jobs on our Jenkins on Monday to see if that is the case.

          Balder VC added a comment -

          LogRotator delegates the delete to the actual Run, for just the log files the delete is delegated all the way to the MavenModuleSetBuild, however for the deleteArtifacts this is not done.

          My knowledge of the Jenkins code base is very small at the moment. Just starting to get a grasp of it. But here is what I mean, https://github.com/redlab/jenkins/commit/d4459d9d0f99b951974f6ab1bedf6a580a some lines of code can say more then words. I've ran all unit tests but didn't add one yet. ( if this could fix it I can create a pull request if you want )

          Balder VC added a comment - LogRotator delegates the delete to the actual Run, for just the log files the delete is delegated all the way to the MavenModuleSetBuild, however for the deleteArtifacts this is not done. My knowledge of the Jenkins code base is very small at the moment. Just starting to get a grasp of it. But here is what I mean, https://github.com/redlab/jenkins/commit/d4459d9d0f99b951974f6ab1bedf6a580a some lines of code can say more then words. I've ran all unit tests but didn't add one yet. ( if this could fix it I can create a pull request if you want )

          Per J. Lund added a comment -

          I have tested your code change in my test environment and it seems to be working!
          The LogRotator plugin now deletes the artifacts and keeps the logs as it should.

          Per J. Lund added a comment - I have tested your code change in my test environment and it seems to be working! The LogRotator plugin now deletes the artifacts and keeps the logs as it should.

            Unassigned Unassigned
            pjoran Per J. Lund
            Votes:
            6 Vote for this issue
            Watchers:
            22 Start watching this issue

              Created:
              Updated:
              Resolved: