Skip to content

[JENKINS-834] add option to keep a number of artifacts #13831

Closed

Description

@jenkins-infra-bot

Currently you can configure a job to keep either artifacts of all builds or only
from the latest successful build.

I have a job with quite large artifacts. I want to keep a long build history
(logs and build times). Also I would like to keep the latest 5 artifacts (or so)
to be able to analyze them etc..

For this to work I would like to have an option in the artifacts settings:
Instead of:
[ ] Discard all but the last successful artifact to save disk space
I propose:
[ ] Keep only artifacts of the last [] successful builds to save disk space


Originally reported by gradopado, imported from: add option to keep a number of artifacts
  • assignee: abayer
  • status: Closed
  • priority: Major
  • component(s): core
  • resolution: Fixed
  • resolved: 2010-03-05T12:51:48+00:00
  • votes: 22
  • watchers: 7
  • imported: 2025-11-24
Raw content of original issue

Currently you can configure a job to keep either artifacts of all builds or only from the latest successful build.

I have a job with quite large artifacts. I want to keep a long build history (logs and build times). Also I would like to keep the latest 5 artifacts (or so) to be able to analyze them etc..

For this to work I would like to have an option in the artifacts settings: Instead of: [ ] Discard all but the last successful artifact to save disk space I propose: [ ] Keep only artifacts of the last [<number>] successful builds to save disk space

  • environment: Platform: All, OS: All

Activity

  1. jenkins-infra-bot commented on Feb 25, 2009

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

      I have the same requirement. I don't want to delete the build, because once you delete the build then you lose all your history then i won't be able to produce the metrics....etc.

      o We also move our artifacts into our centralized server using scp plugin, so there is no need for hudson to keep them once we moved. o As the data grow, hudson takes longer to load during the first time.

    I have the same requirement. I don't want to delete the build, because once you
    delete the build then you lose all your history then i won't be able to produce
    the metrics....etc.

    o We also move our artifacts into our centralized server using scp plugin, so
    there is no need for hudson to keep them once we moved.
    o As the data grow, hudson takes longer to load during the first time.

  2. jenkins-infra-bot commented on Feb 25, 2009

    @jenkins-infra-bot
    Author
    mdonohue:
    • Original comment link
    • Raw content of original comment:
          • Issue 2144 has been marked as a duplicate of this issue. ***
        • Issue 2144 has been marked as a duplicate of this issue. ***
  3. jenkins-infra-bot commented on Feb 25, 2009

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

      Or maybe offer configuration for the number of artifacts to keep. Thanks

    Or maybe offer configuration for the number of artifacts to keep. Thanks

  4. jenkins-infra-bot commented on Feb 26, 2009

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

      There is now main/test/src/test/java/hudson/tasks/ArtifactArchiverTest.java so it would not likely be too hard.

    There is now main/test/src/test/java/hudson/tasks/ArtifactArchiverTest.java so
    it would not likely be too hard.

  5. jenkins-infra-bot commented on Feb 26, 2009

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

      I think this is also relatively easy to do as a plugin, which allows you to define a large amount of options for a desirable behavior.

    I think this is also relatively easy to do as a plugin, which allows you to
    define a large amount of options for a desirable behavior.

  6. jenkins-infra-bot commented on Mar 30, 2009

    @jenkins-infra-bot
    Author
    mdonohue:
    • Original comment link
    • Raw content of original comment:
          • Issue 3343 has been marked as a duplicate of this issue. ***
        • Issue 3343 has been marked as a duplicate of this issue. ***
  7. jenkins-infra-bot commented on May 10, 2009

    @jenkins-infra-bot
    Author
    mdonohue:
    • Original comment link
    • Raw content of original comment:
          • Issue 1298 has been marked as a duplicate of this issue. ***
        • Issue 1298 has been marked as a duplicate of this issue. ***
  8. jenkins-infra-bot commented on Jun 17, 2009

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

      I would love this feature as part of the Hudson or in a plugin. I just found out the hard way how much data I am keeping as artifacts and more control over how long artifacts are kept would be great.

    I would love this feature as part of the Hudson or in a plugin. I just found
    out the hard way how much data I am keeping as artifacts and more control over
    how long artifacts are kept would be great.

  9. jenkins-infra-bot commented on Aug 11, 2009

    @jenkins-infra-bot
    Author
    mdonohue:
    • Original comment link
    • Raw content of original comment:
          • Issue 4198 has been marked as a duplicate of this issue. ***
        • Issue 4198 has been marked as a duplicate of this issue. ***
  10. jenkins-infra-bot commented on Nov 30, 2009

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

      Hello there, is there something new?. i have exactly the same requirement. At the moment i must remove the artifacts manually every week. Maybe the priority should be set to blocker

    Hello there,
    is there something new?.
    i have exactly the same requirement.
    At the moment i must remove the artifacts manually every week.
    Maybe the priority should be set to blocker

  11. jenkins-infra-bot commented on Nov 30, 2009

    @jenkins-infra-bot
    Author
    mdonohue:

    Voting for the issue would be a more effective way of getting it attention:
    http://issues.jenkins-ci.org/secure/ViewIssue.jspa?id=130907&vote=vote

  12. jenkins-infra-bot commented on Jan 27, 2010

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

      I would also love to have a such a feature.

      Some months ago we did a windows batch script, that keeps artifacts of tagged builds and the latest one:

      @ECHO OFF ECHO delete all builds that are not tagged or the latest one SET JOBSPACE=C:\Dokumente und Einstellungen\Administrator\.hudson\jobs\theproduct\builds

      C: cd "%JOBSPACE%" for /F "delims=!" %%f in ('dir build.xml /s /b') DO ( REM currently editing %%f FINDSTR /C:"/tags/" "%%f" > nul IF ERRORLEVEL 1 (REM echo build was not not tagged IF /I NOT "%%f"=="%JOBSPACE%%BUILD_ID%\build.xml" (REM echo delete %%~dpfarchive (the corresponding archive folder) rd /q /s "%%~dpfarchive" 2>nul ) ) ) ECHO. exit 0

      I think one might take this script and modify it to delete the last n builds

    I would also love to have a such a feature.

    Some months ago we did a windows batch script, that keeps artifacts of tagged builds and the latest one:

    @​ECHO OFF
    ECHO delete all builds that are not tagged or the latest one
    SET JOBSPACE=C:\Dokumente und Einstellungen\Administrator\.hudson\jobs\theproduct\builds

    C:
    cd "%JOBSPACE%"
    for /F "delims=!" %%f in ('dir build.xml /s /b') DO ( REM currently editing %%f
    FINDSTR /C:"/tags/" "%%f" > nul
    IF ERRORLEVEL 1 (REM echo build was not not tagged
    IF /I NOT "%%f"=="%JOBSPACE%%BUILD_ID%\build.xml" (REM echo delete %%~dpfarchive (the corresponding archive folder)
    rd /q /s "%%~dpfarchive" 2>nul
    )
    )
    )
    ECHO.
    exit 0

    I think one might take this script and modify it to delete the last n builds

  13. jenkins-infra-bot commented on Mar 5, 2010

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

      Code changed in hudson User: : abayer Path: trunk/hudson/main/core/src/main/java/hudson/model/Run.java trunk/hudson/main/core/src/main/java/hudson/tasks/LogRotator.java trunk/hudson/main/core/src/main/resources/hudson/tasks/LogRotator/config.jelly trunk/hudson/main/test/src/test/java/hudson/tasks/ArtifactArchiverTest.java trunk/hudson/main/test/src/test/java/hudson/tasks/LogRotatorTest.java trunk/www/changelog.html http://jenkins-ci.org/commit/28293 Log: [FIXED JENKINS-834] Added advanced option to delete artifacts without deleting the rest of the build

    Code changed in hudson
    User: : abayer
    Path:
    trunk/hudson/main/core/src/main/java/hudson/model/Run.java
    trunk/hudson/main/core/src/main/java/hudson/tasks/LogRotator.java
    trunk/hudson/main/core/src/main/resources/hudson/tasks/LogRotator/config.jelly
    trunk/hudson/main/test/src/test/java/hudson/tasks/ArtifactArchiverTest.java
    trunk/hudson/main/test/src/test/java/hudson/tasks/LogRotatorTest.java
    trunk/www/changelog.html
    http://jenkins-ci.org/commit/28293
    Log:
    [FIXED JENKINS-834] Added advanced option to delete artifacts without deleting the rest of the build

  14. jenkins-infra-bot commented on Mar 5, 2010

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

      This will be live in 1.350.

    This will be live in 1.350.

  15. jenkins-infra-bot commented on May 2, 2010

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

      Where exactly can I find the new option?

    Where exactly can I find the new option?

  16. jenkins-infra-bot commented on Jul 14, 2010

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

      @flominator, Go to project configuration, check "Discard Old builds", Click "Advanced", you'll see "Days to keep artifacts" and "Max # of builds to keep with artifacts".

      Outstanding functionality, I'm so happy to see this in here finally

    @​flominator, Go to project configuration, check "Discard Old builds", Click "Advanced", you'll see "Days to keep artifacts" and "Max # of builds to keep with artifacts".

    Outstanding functionality, I'm so happy to see this in here finally

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

    @jenkins-infra-bot
    Author

    [Original is_duplicated_by from Jira: JENKINS-1298]

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

    @jenkins-infra-bot
    Author

    [Original is_duplicated_by from Jira: JENKINS-2144]

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

    @jenkins-infra-bot
    Author

    [Original is_duplicated_by from Jira: JENKINS-3343]

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

    @jenkins-infra-bot
    Author

    [Original is_duplicated_by from Jira: JENKINS-4198]

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

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions