AEM/Jackrabbit content packages allow to place Jars to a package in META-INF/vault/hooks
that will be executed during installation. These hooks have to implement the interface InstallHook
.
InstallHooks are executed for each install phase: PREPARE, INSTALLED and END. If an error occurs FAILED is called for PREPARE or INSTALLED. END is called if installation was successful.
Instead of implementing and creating new Java.jars with every job, Vault-Upgrade-Hooks aims to allow to run Groovy Scripts developed and tested using the CQ Groovy Console [https://github.com/Citytechinc/cq-groovy-console].
- Run Groovy Console Scripts places w/in the package files
- Control if the upgrade is executed by Package and install version.
- Control if the upgrade is executed once or with every install of an package
Two general ways of how to use it:
- ad-hoc admin style:
- take a copy of the sample package (sling pipes or groovy)
- update package info (make sure name, version and group are updated),
- update hook (e.g. test-groovy - replace all scripts with yours, update the run-info (
run
,version
,jcr:title
)) - build and install
- dev-style:
- add a copy job to your maven build (resource plugin) and place the hook.jar
- create a upgrade info folder (like the test-groovy one) and place your scripts in -> part of your deployment process
Run mvn clean install -PautoInstallPackage
Run information is stored in Phase END under:
/var/upgrade/packagegroup/packagename
The hook requires AEM6 SP3. If you need to run this with an earlier version replace org.apache.jackrabbit.vault.packaging.InstallHook
by om.day.jcr.vault.packaging.InstallHook