Build Discarder

Github Build Jenkins Build Jenkins Plugin GitHub release

Introduction

A global build discarder that's possible to override by adding a job specific discarder. The goal is to be able to have a global sensible default, that's possible to override if needed. The minimum supported version of Jenkins is 2.303.1, the goal is to support the two latest versions of Jenkins LTS.

Getting started

The Default Build Discarder can be added here:

Manage Jenkins >> Configure System >> Global Build Discarders

Alt text

Configuration as Code

Add defaultBuildDiscarder to your configuredBuildDiscarders with the standard logRotator settings.

unclassified:
  buildDiscarders:
    configuredBuildDiscarders:
    - "jobBuildDiscarder"
    - defaultBuildDiscarder:
        discarder:
          logRotator:
            artifactDaysToKeepStr: "50"
            artifactNumToKeepStr: "5"
            daysToKeepStr: "100"
            numToKeepStr: "10"

Override the settings with a job specific discarder

Adding a job specific discarder will make sure the Default Build Discarder is not applicable.

# Jenkinsfile
pipeline {
  options {
    buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '30'))
  }
  ...
}

Background

The built in Specific Build Discarder discards builds independent of specific job discarders.

This discarder will not discard any builds if there's a job specific discarder specified. To goal is to be able provide as sensible default that can be overriden on job level when needed.

Contributing

This plugin is probably close to done but if you have an idea, please open an issue so we can discuss the extension.

See the default contribution guidelines for Jenkins

Local development

Start Jenkins by running this command

mvn hpi:run

Release management

The releases is automated via the the github action, using the JEP-229: Continuous Delivery of Jenkins Components and Plugins flow.

Supported versions of Jenkins

We're trying to support the last two LTS versions of Jenkins, see the offical documentation for further details.

Upgrading is done by changing the jenkins version with the matching bom. See this example for how to update the version.