Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Is there a tool or system to migrate JCR component level changes?

Avatar

Level 9

let's say you develop a component to display some images based on a category field.  This gets deployed to your 5 cloud environments (dev, test, UAT, stage, prod etc).

 

On production and UAT the Content Authors add this component to various pages, and set the category values.

 

You now develop a new version of this component which you remove the category field, and add new fields such as categoryList.

 

When this new version of the component get deployed to each cloud environment, all pages which use this component get broken, as they expect a categoryList field.

 

We would want to run a script to add the new field to all existing instances of the component, and set its value to an array with the value of the old category field as the only element.  This would only run once, if not already run for that env.

 

This is very similar to migrating a SQL database change.  For this you would use a tool such as liquibase, which has  change scripts which get run when the system boots, if that script wasnt previously applied.  Liquibase happens to use scripts which contain SQL statements (for simple table structure or data changes), but could also contain code (for more complex changes).

 

This must be a pretty common problem for AEM?

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @TB3dock,

I would recommend to use AEM Easy Content Upgrade tool

This is tool that will allow you to run groovy script automatically, as part of package installation.

Here are also other pros:

  • it is compatible with AEM as a Cloud Service
  • it includes groovy console and all dependencies needed to run it
  • it allows to run groovy script automatically, and make sure it will not be run again
  • it provides GUI that will allow you to check the results of any groovy script executed via AECU and trigger it manually once again if needed

Alternatively you can use Groovy Console as a stand alone tool:

But in that case you will need to run your scripts manually on each instance and each environment.

View solution in original post

6 Replies

Avatar

Correct answer by
Community Advisor

Hi @TB3dock,

I would recommend to use AEM Easy Content Upgrade tool

This is tool that will allow you to run groovy script automatically, as part of package installation.

Here are also other pros:

  • it is compatible with AEM as a Cloud Service
  • it includes groovy console and all dependencies needed to run it
  • it allows to run groovy script automatically, and make sure it will not be run again
  • it provides GUI that will allow you to check the results of any groovy script executed via AECU and trigger it manually once again if needed

Alternatively you can use Groovy Console as a stand alone tool:

But in that case you will need to run your scripts manually on each instance and each environment.

Avatar

Level 9

Hi, I tried to install this tool by putting this in the pom.xml for our cloud version (running locally), but it doesn't install it.

 

    <dependency>
        <groupId>de.valtech.aecu</groupId>
        <artifactId>aecu.complete.cloud</artifactId>
        <version>LATEST</version>
        <type>zip</type>
    </dependency>

After doing 

 

% mvn clean install -PautoInstallSinglePackageAuthor

 

There is no groovy console at http://localhost:4502/groovyconsole

and no "aem easy content upgrade" menu in author.

 

There is only this warning in the build output (and no errors):

 

[^[[1;33mWARNING^[[m] 'dependencyManagement.dependencies.dependency.version' for de.valtech.aecu:aecu.complete.cloud:zip is either LATEST or RELEASE (both of them are being deprecated) @ line 715, column 22

 

 

Avatar

Community Advisor

Adding dependency is not suffice. You need to embed the package to get it deployed on AEM. 
Like you do with any other dependency e.g. ACS commons package 

https://www.linkedin.com/pulse/how-add-third-party-bundle-you-aem-package-veena-vikraman - check this one for reference 

 

Avatar

Level 9

Thanks!  Ive downloaded the zip, but the next missing piece is where to put it.  The example link you kindly provided uses \ui.apps\src\main\content\jcr_root\apps\<project> but this is for a different kind of install, its for some sort of embedded plugin, not for a dependency.    Also, that link has a completely different mvn entry, specifying specific directories etc. which is not how mvn is specified in this packages install instructions.

 

I also checked out these install instructions:

https://adobe-consulting-services.github.io/acs-aem-commons/pages/maven.html

 

But there is no mention of manually downloading packages and where to put them (in addition to that pulled in automatically via mvn).

 

In a java project which does not use mvn, you would put any libs on the class path.  Not sure what the AEM equivalent of this is.

 

Note: mvn is supposed to download and configure dependencies automatically. If I have to install something locally, it wont work when deployed to cloud envs via CDI pipeline.

Avatar

Level 9

Ive installed the tool and groovy console, but cant figure out how to get a script into the system. The docs mention these two directories:

 

  • /apps/aecu-scripts (AEM Cloud automatic execution with startup hook, since 6.0.0)
  • /conf/groovyconsole/scripts/aecu (AEM onprem manual and install hook execution, AEM Cloud manual execution)

 

But of course this directory structure does not exist in AEM.  AEM as the following structure:

all

core

dispatcher

ui.apps

etc.

 

I tried creating a directory /apps/aecu-scripts and added one script:

sample.groovy

aecu.contentUpgradeBuilder()

        .forChildResourcesOf("/content/mysite/uk/en/")

        .filterByNodeName("jcr:content")

        .printPath()

        .printProperty("sling:resourceType")

        .printJson()

        .run()

 

Then I build the project using "mvn install -PautoInstallPackage".

However, nothing shows up in "AEM Easy Content Upgrade - Execute"

 

Anyone seen a project with a hello world script so we can see how to get a script into the system?

Avatar

Community Advisor

@TB3dock As @lukasz-m mentioned AECU tool is the fit for your requirement. Whatever pros already mentioned, on the top of it, script written with AECU are indeed compact and saves a lot of boilerplate code.
If not AECU then standard Groovy script is the way.