Deleting old packages programatically in AEM | Community
Skip to main content
Level 3
March 21, 2020
Solved

Deleting old packages programatically in AEM

  • March 21, 2020
  • 1 reply
  • 7422 views

Hi All,

We have our code deployment to AEM servers using curl command through CI-CD pipelines. While the number of deployments (packages being deployed) per day is more compared to UAT and Prod, we now have a huge amount of redundant old packages lying which is taking more disk space and slowing the performance of AEM especially Package manager screen. Is there a way to delete old packages during new code deployment (through curl or any other means) or a maintenance task or programatic way to delete these old packages?

 

Thanks in advance!

Regards,

Ashwin Raju

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Nirmal_Jose

If you delete a a package, there are various problems/inconsistencies that may come up.
1. If you have subpackages, they won't get deleted. eg. adobe core components package
2. If you have bundles, they won't get deleted.


So ideally you should include the uninstall the package. This step as the first step in your deployment process.
1. if you have a blue green deployment strategy, you can uninstall until the latest version.
2. If not, you can think of the below process with a rule to uninstall until n-1 version.

 

For uninstall, there is no straight away API to consume, but the best way is

1. Fetch the list of packages /crx/packmgr/list.jsp using curl

2. Parse the results with any identifier like package name in the pipeline

3. Invoke uninstall using curl like curl -u admin:admin -F cmd=uninstall http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/test.zip

 

A ruby gem reference which can outline the delete process(not uninstall process) is available at [1] and a brilliant article on the whole deployment strategy is at [2]. 
[1] - https://github.com/vrtdev/aemcrxpkgmgr/blob/d62c151ee6a6858ce1d769f8ae9a0696ff040a7c/lib/aemcrxpkgmgr.rb
[2] - https://medium.com/vrt-digital-studio/13-steps-to-rock-stable-aem-package-installs-d9bbba1f7b15
Thanks,

Nirmal Jose

1 reply

Nirmal_Jose
Adobe Employee
Nirmal_JoseAdobe EmployeeAccepted solution
Adobe Employee
March 22, 2020

If you delete a a package, there are various problems/inconsistencies that may come up.
1. If you have subpackages, they won't get deleted. eg. adobe core components package
2. If you have bundles, they won't get deleted.


So ideally you should include the uninstall the package. This step as the first step in your deployment process.
1. if you have a blue green deployment strategy, you can uninstall until the latest version.
2. If not, you can think of the below process with a rule to uninstall until n-1 version.

 

For uninstall, there is no straight away API to consume, but the best way is

1. Fetch the list of packages /crx/packmgr/list.jsp using curl

2. Parse the results with any identifier like package name in the pipeline

3. Invoke uninstall using curl like curl -u admin:admin -F cmd=uninstall http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/test.zip

 

A ruby gem reference which can outline the delete process(not uninstall process) is available at [1] and a brilliant article on the whole deployment strategy is at [2]. 
[1] - https://github.com/vrtdev/aemcrxpkgmgr/blob/d62c151ee6a6858ce1d769f8ae9a0696ff040a7c/lib/aemcrxpkgmgr.rb
[2] - https://medium.com/vrt-digital-studio/13-steps-to-rock-stable-aem-package-installs-d9bbba1f7b15
Thanks,

Nirmal Jose

Level 4
March 23, 2020
Thanks for liking my article Nirmal!