Skip to content

feat(cleanDockerImages): Add globalMaxDays and globalMaxCount#495

Open
g3n35i5 wants to merge 1 commit into
jfrog:masterfrom
vorausrobotik:feat/cleanupDockerGlobalProps
Open

feat(cleanDockerImages): Add globalMaxDays and globalMaxCount#495
g3n35i5 wants to merge 1 commit into
jfrog:masterfrom
vorausrobotik:feat/cleanupDockerGlobalProps

Conversation

@g3n35i5

@g3n35i5 g3n35i5 commented Jan 19, 2026

Copy link
Copy Markdown

Add Global Retention Policy Fallbacks for cleanDockerImages Plugin

Overview

This PR extends the cleanDockerImages plugin to support optional global fallback values for retention policies, eliminating the need to manually label every Docker image with retention policies.

Motivation

Previously, each Docker image had to be explicitly labeled with com.jfrog.artifactory.retention.maxDays and/or com.jfrog.artifactory.retention.maxCount in its Dockerfile. This approach had limitations:

  • Requires rebuilding images to change retention policies
  • Not practical for third-party images that can't be modified
  • Tedious to manage retention across many images
  • No way to set repository-wide defaults

Changes

New Configuration Options

Added two optional configuration parameters to cleanDockerImages.properties:

  • globalMaxDays: Global fallback for maximum age retention (in days)
  • globalMaxCount: Global fallback for maximum version count retention

These values apply to images that don't have explicit labels set. Set to null or omit to disable.

Implementation Details

  • Global settings are loaded from the properties file on plugin execution
  • Image-specific labels always take precedence over global settings
  • Both maxDays and maxCount policies work with global fallbacks
  • Compatible with existing byDownloadDate behavior

Code Changes

  • Modified checkDaysPassedForDelete() and getMaxCountForDelete() to accept and use global fallback parameters
  • Updated function signatures throughout the call chain to pass global settings
  • Added type checking to handle both String (from labels) and Integer (from global config) property values
  • Enhanced logging to indicate when global values are being used

Backward Compatibility

This change is fully backward compatible:

  • Existing configurations without global settings continue to work unchanged
  • Image-specific labels are still supported and take priority
  • No breaking changes to the plugin API or execution parameters

Usage Example

# cleanDockerImages.properties
dockerRepos = ["docker-local", "docker-prod"]
byDownloadDate = false
globalMaxDays = 30
globalMaxCount = 5

@github-actions

github-actions Bot commented Jan 19, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@g3n35i5 g3n35i5 force-pushed the feat/cleanupDockerGlobalProps branch from 8b857b2 to 89778a0 Compare January 19, 2026 10:59
@g3n35i5

g3n35i5 commented Jan 19, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

This PR extends the `cleanDockerImages` plugin to support optional global fallback values for retention policies, eliminating the need to manually label every Docker image with retention policies.

Previously, each Docker image had to be explicitly labeled with `com.jfrog.artifactory.retention.maxDays` and/or `com.jfrog.artifactory.retention.maxCount` in its Dockerfile. This approach had limitations:

- Requires rebuilding images to change retention policies
- Not practical for third-party images that can't be modified
- Tedious to manage retention across many images
- No way to set repository-wide defaults

Added two optional configuration parameters to `cleanDockerImages.properties`:

- **`globalMaxDays`**: Global fallback for maximum age retention (in days)
- **`globalMaxCount`**: Global fallback for maximum version count retention

These values apply to images that don't have explicit labels set. Set to `null` or omit to disable.

- Global settings are loaded from the properties file on plugin execution
- Image-specific labels always take precedence over global settings
- Both `maxDays` and `maxCount` policies work with global fallbacks
- Compatible with existing `byDownloadDate` behavior

- Modified `checkDaysPassedForDelete()` and `getMaxCountForDelete()` to accept and use global fallback parameters
- Updated function signatures throughout the call chain to pass global settings
- Added type checking to handle both String (from labels) and Integer (from global config) property values
- Enhanced logging to indicate when global values are being used

**This change is fully backward compatible:**

- Existing configurations without global settings continue to work unchanged
- Image-specific labels are still supported and take priority
- No breaking changes to the plugin API or execution parameters

```groovy

dockerRepos = ["docker-local", "docker-prod"]
byDownloadDate = false
globalMaxDays = 30
globalMaxCount = 5
@g3n35i5 g3n35i5 force-pushed the feat/cleanupDockerGlobalProps branch from 89778a0 to b20ecda Compare January 19, 2026 13:25
@g3n35i5

g3n35i5 commented Feb 9, 2026

Copy link
Copy Markdown
Author

@jfrogdixit pinging you since you're the latest contributor with merge permissions. Do you have an ETA for a review?
Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant