Managing AEM Packages from the CLI

Published on by Dan KlcoPicture of Me Dan Klco

After the umpteenth time of having to check this excellent reference of the cURL commands for AEM to upload a package, I finally thought "this is silly". So, I created a small script to make it easier to manage packages via the command line.

The AEM Package Manager is just that, a small script to help you manage scripts from the command line. This script is useful for many occasions, such as:

  • Exchanging content packages
  • Installing a dependency package outside the build
  • Or when you just want something quicker and easier than using the AEM web UI to upload a package

Using the script is as simple as:

  • Downloading the script from GitHub
  • Making it executable
  • Putting it in your system path

Once you have the script installed, you can use it as shown in the following examples:

List Packages

Lists all of the packages in the my_packages group.

danklco@EDS-Klco-MAC ~> aem-pkmgr list -g my_packages

Group: my_packages
Path: /etc/packages/my_packages/

Group: my_packages
Path: /etc/packages/my_packages/

Version: tes
Group: my_packages
Path: /etc/packages/my_packages/

Download Package

Downloads the package /etc/packages/my_packages/

danklco@EDS-Klco-MAC ~> aem-pkmgr download -pk /etc/packages/my_packages/
DOWNLOADING PACKAGE /etc/packages/my_packages/
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 41.3M 100 41.3M 0 0 140M 0 --:--:-- --:--:-- --:--:-- 140M

Upload / Install Package

Uploads and installs the package

danklco@EDS-Klco-MAC ~> aem-pkmgr upload-install -pk 
<crx version="1.2.2" user="admin" workspace="crx.default">
<param name="file" value=""/>
<param name="force" value="true"/>
<param name="install" value="true"/>
<created>Wed, 20 Jul 2016 12:41:05 -0500</created>
<lastModified>Wed, 20 Jul 2016 12:40:26 -0500</lastModified>
<lastUnpacked>Wed, 20 Jul 2016 15:33:04 -0500</lastUnpacked>
Installing content...
Collecting import information...
Installing node types...
- rep -&gt; internal
- mix -&gt;
- nt -&gt;
- sling -&gt;
- cq -&gt;
- sling:Folder
- sling:Redirect
- sling:Resource
- cq:ReplicationStatus
- cq:Tag
- rep:RepoAccessControllable
Installing privileges...
Importing content...
- /
- /etc
- /etc/tags
[... trim ...]
saving approx 0 nodes...
Package imported.
Package installed in 55497ms.
<status code="200">ok</status>

Hopefully, this helps you manage AEM packages via the command line. You can find more detailed usage documentation on the GitHub site.

If you have any questions or you'd like to see something added, leave a comment here or create an issue.


comments powered by Disqus