AEM Groovy Console
The AEM Groovy Console provides an interface for running Groovy scripts in Adobe Experience Manager. Scripts can be created to manipulate content in the JCR, call OSGi services, or execute arbitrary code using the AEM, Sling, or JCR APIs. After installing the package in AEM (instructions below), see the console page for documentation on the available bindings and methods. Sample scripts are included in the package for reference.
|Groovy Console Version(s)||AEM Version|
|6.x.x, 5.x.x||5.6 (CQ)|
|3.x.x||5.5, 5.4 (CQ)|
Download the console package. For previous versions, tags can be checked out from GitHub and built directly from the source (e.g.
Verify the installation.
Additional build profiles may be added in the project's
pom.xml to support deployment to non-localhost AEM servers.
AEM 6.0 no longer allows vanity paths for pages in
/etc by default. To enable access to the Groovy Console from
/groovyconsole as in previous versions, the Apache Sling Resource Resolver Factory OSGi configuration must be updated to allow vanity paths from
/etc. The Groovy Console Configuration Service can then be updated to enable the vanity path if so desired.
Building From Source
To build and install the latest development version of the Groovy Console (or if you've made source modifications), run the following Maven command.
mvn install -P local
Excluding the Groovy OSGi Bundle
If your AEM instance has multiple applications using Groovy and the
groovy-all bundle is already deployed, you can exclude this bundle from the Groovy Console package build with the
exclude-groovy-bundle Maven profile. This should prevent issues with conflicting Groovy versions at runtime.
mvn install -P local,exclude-groovy-bundle
Context Path Support
If you are running AEM with a context path, set the Maven property
aem.context.path during installation.
mvn install -P local -Daem.context.path=/context
Navigate to the OSGi console configuration page and select the Groovy Console Configuration Service.
|Email Enabled?||Check to enable email notification on completion of script execution.||
|Email Recipients||Email addresses to receive notification.||
|Allowed Groups||List of group names that are authorized to use the console. If empty, no authorization check is performed.||
|Vanity Path Enabled?||Enables
|Audit Disabled?||Disables auditing of script execution history.||
|Display All Audit Records?||If enabled, all audit records (including records for other users) will be displayed in the console history.||
Batch Script Execution
Saved scripts can be remotely executed by sending a POST request to the console servlet with either the
scriptPaths query parameter.
curl -d "scriptPath=/etc/groovyconsole/scripts/samples/JcrSearch.groovy" -X POST -u admin:admin http://localhost:4502/bin/groovyconsole/post.json
curl -d "scriptPaths=/etc/groovyconsole/scripts/samples/JcrSearch.groovy&scriptPaths=/etc/groovyconsole/scripts/samples/FulltextQuery.groovy" -X POST -u admin:admin http://localhost:4502/bin/groovyconsole/post.json
Beginning in version 7.0.0, the Groovy Console provides extension hooks to further customize script execution. The console exposes an API containing three extension provider interfaces that can be implemented as OSGi services in any bundle deployed to an AEM instance. See the default extension providers in the
com.icfolson.aem.groovy.console.extension.impl package for examples of how a bundle can implement these services to supply additional script bindings, metaclasses, and star imports.
To provide custom notifications for script executions, bundles may implement the
com.icfolson.aem.groovy.console.notification.NotificationService interface (see the
com.icfolson.aem.groovy.console.notification.impl.EmailNotificationService class for an example). These services will be dynamically bound by the Groovy Console service and all registered notification services will be called for each script execution.
Sample scripts can be found in the
Follows Semantic Versioning guidelines.