Automatically purge packages according to a user-defined policy
You can create a package retention policy (
policy.PackageRetentionPolicy) that removes all deployment packages except the last ‘N’ packages that match a regular expression that you define. Packages are sorted in lexicographical order.
Deployed packages are never removed by the package retention policy. If a deployed package is part of the packages identified for removal, then it will be skipped, with no impact on the other packages.
Note: Executing a package retention policy does not automatically reclaim disk space freed up by removing the packages. See Reclaim disk space on an XL Deploy server for more information.
To automatically purge old deployment packages using a policy:
- From the side bar, click Configuration.
- Click , then select New > Policy >
- In the Name field, type a unique policy name.
- In the Regex pattern field, specify a regular expression that matches the packages to which the policy should apply.
- In the Packages to retain field, type the number of deployment packages to retain per application.
Note: By default, automatic policy execution is enabled and will run according to the crontab scheduled defined on the Schedule tab. You can optionally change the crontab schedule or disable execution.
Tip: You can manually execute a package retention policy by right-clicking it and selecting Execute job now.
You can create multiple package retention policies. For example:
- Regex pattern:
- Packages to retain: 30
0 0 18 * * *
- Regex pattern:
- Packages to retain: 10
0 0 18 30 * *
Important: Package retention policies are executed independently, so ensure that you define a regular expression that excludes packages that are covered by other policies.
An application has the following deployment packages:
Package 1.0 is deployed to the PROD environment and 4.0 is deployed to the DEV environment.
Assuming a package retention policy that retains the last 3 packages and uses the ReleasePackagePolicy regular expression pattern defined above, the packages to be removed will be: 2.0.