Skip to content

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

Closed

Description

@jenkins-infra-bot

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).


Originally reported by pjoran, imported from: The 'Discard Old Builds' advanced option - removal of only artifacts - does not work for me after 1.503.
  • status: Resolved
  • priority: Major
  • component(s): core
  • label(s): 1.509.3-fixed
  • resolution: Fixed
  • resolved: 2014-03-27T22:13:57+00:00
  • votes: 6
  • watchers: 22
  • imported: 2025-11-24
Raw content of original issue

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).

  • environment: Fedora 18 x86_64

Activity

  1. jenkins-infra-bot commented on Apr 8, 2013

    @jenkins-infra-bot
    Author
    pjoran:
    • Original comment link
    • Raw content of original 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.

    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> 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.

  2. jenkins-infra-bot commented on Apr 9, 2013

    @jenkins-infra-bot
    Author
    gcummings:
    • Original comment link
    • Raw content of original 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.

    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.
  3. jenkins-infra-bot commented on Apr 9, 2013

    @jenkins-infra-bot
    Author
    pjoran:
    • Original comment link
    • Raw content of original 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...

    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...

  4. jenkins-infra-bot commented on Apr 12, 2013

    @jenkins-infra-bot
    Author
    redlab:
    • Original comment link
    • Raw content of original 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.

    It seems to me that each of the modules have their own configuration file. But the tag e.g.

    -1
    50
    -1
    2

    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.

  5. jenkins-infra-bot commented on Apr 15, 2013

    @jenkins-infra-bot
    Author
    redlab:
    • Original comment link
    • Raw content of original 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 )

    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 )

  6. jenkins-infra-bot commented on Apr 16, 2013

    @jenkins-infra-bot
    Author
    pjoran:
    • Original comment link
    • Raw content of original 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.

    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.

  7. jenkins-infra-bot commented on Apr 16, 2013

    @jenkins-infra-bot
    Author
    redlab:
    • Original comment link
    • Raw content of original comment:

      Great, I had some merge issues with the pull request yesterday night. I'll try send a new one to jenkins-ci github

    Great, I had some merge issues with the pull request yesterday night. I'll try send a new one to jenkins-ci github

  8. jenkins-infra-bot commented on Apr 16, 2013

    @jenkins-infra-bot
    Author
    redlab:

    I've send a pull request, #759 AFIAK there no merge issues on my side. Maybe there's an issue with the workspace at https://jenkins.ci.cloudbees.com/job/core/job/jenkins_main_trunk/

  9. jenkins-infra-bot commented on May 2, 2013

    @jenkins-infra-bot
    Author
    scm_issue_link:

    Code changed in jenkins
    User: redlab
    Path:
    maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java
    http://jenkins-ci.org/commit/jenkins/d4459d9d0f99b951974f6ab1bedf6a580aad9248
    Log:
    As this is my first look inside Jenkins codebase I not sure it's correct
    but perhaps artifacts for modulebuilds should be deleted just as logs
    are deleted. see https://issues.jenkins-ci.org/browse/JENKINS-17508
    I did not fully test it yet, all unit tests ran fine, but didn't succeed
    to run jobs inside Jenkins, due to classloader issues while running
    Jenkins in Jetty, to verify deletion

  10. jenkins-infra-bot commented on May 2, 2013

    @jenkins-infra-bot
    Author
    scm_issue_link:
    • Original comment link
    • Raw content of original comment:

      Code changed in jenkins User: redlab Path: test/src/test/java/hudson/maven/MavenMultiModuleLogRotatorCleanArtifacts.java test/src/test/java/hudson/maven/MavenMultiModuleLogRotatorCleanArtifactsTest.java http://jenkins-ci.org/commit/jenkins/aa1d28b04014c18838e87b3a8b1707cc5eb28b14 Log: JENKINS-17508 updated the test to use @Rule and no longer extend from the old HudsonTestCase (shouldn't that one be marked deprecated?), add @ Bug and @ For as jesse suggested

    Code changed in jenkins
    User: redlab
    Path:
    test/src/test/java/hudson/maven/MavenMultiModuleLogRotatorCleanArtifacts.java
    test/src/test/java/hudson/maven/MavenMultiModuleLogRotatorCleanArtifactsTest.java
    http://jenkins-ci.org/commit/jenkins/aa1d28b04014c18838e87b3a8b1707cc5eb28b14
    Log:
    JENKINS-17508 updated the test to use @​Rule and no longer extend from the old HudsonTestCase (shouldn't that one be marked deprecated?), add @ Bug and @ For as jesse suggested

  11. jenkins-infra-bot commented on May 2, 2013

    @jenkins-infra-bot
    Author
    scm_issue_link:

    Code changed in jenkins
    User: redlab
    Path:
    test/src/test/java/hudson/maven/MavenMultiModuleLogRotatorCleanArtifactsTest.java
    http://jenkins-ci.org/commit/jenkins/f9ce6558c93d7f7ff0f8df12fb80f9ecc868ff99
    Log:
    JENKINS-17508 removed usage of deprecated elements in test

  12. jenkins-infra-bot commented on May 2, 2013

    @jenkins-infra-bot
    Author
    scm_issue_link:

    Code changed in jenkins
    User: Jesse Glick
    Path:
    maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java
    test/src/test/java/hudson/maven/MavenMultiModuleLogRotatorCleanArtifactsTest.java
    http://jenkins-ci.org/commit/jenkins/153c9a65ca1393e97a76588d7076883ec39710c5
    Log:
    Merge pull request #759 from redlab/JENKINS-17508

    [FIXED JENKINS-17508] Artifacts not being deleted by LogRotator

    Compare: 31eeb75...153c9a6

  13. jenkins-infra-bot commented on May 2, 2013

    @jenkins-infra-bot
    Author
    scm_issue_link:

    Code changed in jenkins
    User: Jesse Glick
    Path:
    changelog.html
    http://jenkins-ci.org/commit/jenkins/09ae9c00d39dbe824e5f0fdcd8861ec245ed057f
    Log:
    JENKINS-17508 Noting.

  14. jenkins-infra-bot commented on May 2, 2013

    @jenkins-infra-bot
    Author
    dogfood:

    Integrated in jenkins_main_trunk #2507
    JENKINS-17508 updated the test to use @​Rule and no longer extend from the old HudsonTestCase (shouldn't that one be marked deprecated?), add @ Bug and @ For as jesse suggested (Revision aa1d28b)
    JENKINS-17508 removed usage of deprecated elements in test (Revision f9ce655)
    JENKINS-17508 Noting. (Revision 09ae9c0)

    Result = SUCCESS
    balder : aa1d28b04014c18838e87b3a8b1707cc5eb28b14
    Files :

    • test/src/test/java/hudson/maven/MavenMultiModuleLogRotatorCleanArtifactsTest.java
    • test/src/test/java/hudson/maven/MavenMultiModuleLogRotatorCleanArtifacts.java

    balder : f9ce6558c93d7f7ff0f8df12fb80f9ecc868ff99
    Files :

    • test/src/test/java/hudson/maven/MavenMultiModuleLogRotatorCleanArtifactsTest.java

    Jesse Glick : 09ae9c00d39dbe824e5f0fdcd8861ec245ed057f
    Files :

    • changelog.html
  15. jenkins-infra-bot commented on May 23, 2013

    @jenkins-infra-bot
    Author
    tomekk:
    • Original comment link
    • Raw content of original comment:

      I've upgraded to Jenkins 1.515 from 1.506 exactly because I wanted this functionality to work but it still does not remove old modules from SOME_JOB/modules/SOME_MODULE/builds

    I've upgraded to Jenkins 1.515 from 1.506 exactly because I wanted this functionality to work but it still does not remove old modules from SOME_JOB/modules/SOME_MODULE/builds

  16. 15 remaining items

  17. jenkins-infra-bot commented on Dec 20, 2013

    @jenkins-infra-bot
    Author
    baboulama:
    • Original comment link
    • Raw content of original comment:

      Hello,

      We're running Jenkins 1.533 and we still notice the same behavior reported by Sergei Ivanov. Even though we have old builds properly deleted, the clean is not propagated to the underlying modules for which we keep having a bunch of orphans.

      Best regards.

    Hello,

    We're running Jenkins 1.533 and we still notice the same behavior reported by Sergei Ivanov.
    Even though we have old builds properly deleted, the clean is not propagated to the underlying modules for which we keep having a bunch of orphans.

    Best regards.

  18. jenkins-infra-bot commented on Jan 28, 2014

    @jenkins-infra-bot
    Author
    sc_rsc:
    • Original comment link
    • Raw content of original comment:

      Got an Jan 28, 2014 9:03:44 AM hudson.model.Run execute SEVERE: Failed to rotate log java.io.IOException: e:\jenkins\jobs\<.....>\modules\com.<...>$<....>\builds\2013-10-23_11-57-46 looks to have already been deleted {{ at hudson.model.Run.delete(Run.java:1432)}} {{ at hudson.maven.MavenModuleSetBuild.delete(MavenModuleSetBuild.java:430)}} {{ at hudson.tasks.LogRotator.perform(LogRotator.java:124)}} {{ at hudson.model.Job.logRotate(Job.java:437)}} {{ at hudson.maven.MavenModuleSet.logRotate(MavenModuleSet.java:840)}} {{ at hudson.model.Run.execute(Run.java:1728)}} {{ at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:519)}} {{ at hudson.model.ResourceController.execute(ResourceController.java:88)}} {{ at hudson.model.Executor.run(Executor.java:246)}} with Jenkins ver. 1.532.1. (Mentioned directory 2013-10-23_11-57-46 is not existing on file system).

      LogRotator should continue deleting all other matching jobs.

    Got an
    Jan 28, 2014 9:03:44 AM hudson.model.Run execute
    SEVERE: Failed to rotate log
    java.io.IOException: e:\jenkins\jobs\<.....>\modules\com.<...>$<....>\builds\2013-10-23_11-57-46 looks to have already been deleted
    {{ at hudson.model.Run.delete(Run.java:1432)}}
    {{ at hudson.maven.MavenModuleSetBuild.delete(MavenModuleSetBuild.java:430)}}
    {{ at hudson.tasks.LogRotator.perform(LogRotator.java:124)}}
    {{ at hudson.model.Job.logRotate(Job.java:437)}}
    {{ at hudson.maven.MavenModuleSet.logRotate(MavenModuleSet.java:840)}}
    {{ at hudson.model.Run.execute(Run.java:1728)}}
    {{ at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:519)}}
    {{ at hudson.model.ResourceController.execute(ResourceController.java:88)}}
    {{ at hudson.model.Executor.run(Executor.java:246)}}
    with Jenkins ver. 1.532.1.
    (Mentioned directory 2013-10-23_11-57-46 is not existing on file system).

    LogRotator should continue deleting all other matching jobs.

  19. jenkins-infra-bot commented on Mar 27, 2014

    @jenkins-infra-bot
    Author
    jglick:
    • Original comment link
    • Raw content of original comment:

      @baboulama, @sc_rsc: the originally reported bug here is fixed; do not reopen.

    @​baboulama, @​sc_rsc: the originally reported bug here is fixed; do not reopen.

  20. jenkins-infra-bot commented on Mar 27, 2014

    @jenkins-infra-bot
    Author
    jglick:
    • Original comment link
    • Raw content of original comment:

      Filed JENKINS-22395 for a problem actually deleted old builds under unknown conditions.

    Filed JENKINS-22395 for a problem actually deleted old builds under unknown conditions.

  21. jenkins-infra-bot commented on Nov 24, 2025

    @jenkins-infra-bot
    Author

    [Original duplicates from Jira: JENKINS-17355]

  22. jenkins-infra-bot commented on Nov 24, 2025

    @jenkins-infra-bot
    Author

    [Original is_duplicated_by from Jira: JENKINS-17553]

  23. jenkins-infra-bot commented on Nov 24, 2025

    @jenkins-infra-bot
    Author

    [Original relates_to from Jira: JENKINS-22395]

  24. removed
    bugFor changelog: Minor bug. Will be listed after features
    on Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions