Back to blog

Plugin of the Month – June 2026: Build Discarder Plugin

Mark Schulz
June 13, 2026 ⏱︎ 4 min read

Welcome back to the Plugin of the Month series, where we highlight useful and impactful plugins from the Jenkins ecosystem.

For June 2026, we’re featuring the Build Discarder Plugin.

Do you maintain a Jenkins server with thousands of active users? And even more builds? Spring cleaning? Or you just want to keep things neat and tidy? A global configuration for your build items can help, because this is one of those things that is easy to forget until it becomes a problem. This month, we are highlighting the Build Discarder Plugin.

What is the Build Discarder Plugin?

Jenkins comes with a built-in build discarder that can be configured per job — but that only works well when every user or team manages its own settings. The Build Discarder Plugin takes it a step further by adding a global default that only kicks in when no job-specific discarder is set.

The idea is elegant in its simplicity: define a smart server-wide policy once, and let individual jobs override it whenever they need something different. This trick will save you time and discussions, or simply help keep your environment tidy.

Key Features

1. Global Defaults

The core feature is the Default Build Discarder, which you configure once under:

Manage Jenkins → System → Global Build Discarders

Choose between Days to keep builds, Max # of builds to keep, Days to keep artifacts, Max # of builds to keep with artifacts, or combine both - your choice.

We set Max # of builds to keep to 20

2. Per-Job Override — No Surprises

Everyone can configure their jobs individually to their liking in the job configuration.

This means your release pipeline builds can be kept for 90 days, your feature branch jobs can be discarded after 5 builds, your artifacts can be removed before the build logs. Your builds which you kept forever do not count.

Getting Started in a Pipeline

Using a job-specific discarder in your Jenkinsfile is another way to define your options:

pipeline {
    options {
      buildDiscarder logRotator(
        daysToKeepStr: '10',          // discard builds older than 10 days
        numToKeepStr: '20',           // keep at most 20 builds
        artifactDaysToKeepStr: '5',   // discard artifacts older than 5 days
        artifactNumToKeepStr: '10'    // keep artifacts for the last 10 builds
      )
    }
  [...]
}

Jobs that do not define this block will fall back to whatever you have configured as the global default.

Why This Matters

The Build Discarder Plugin solves a real operational pain point. Asking every team to configure their own retention policy is error-prone, time-consuming and easy to forget but still provides the freedom to do what they want.

Explore the plugin today on the Jenkins Plugin Site!

About the author

Mark Schulz

In my day job, I’m a DevOps engineer in a central team that provides Jenkins and other DevOps tooling.