Skip to content

AEM – Automation – Deploy & Replicate Package

-== Disclaimer ==-

If you require any more information or have any questions about our site’s disclaimer, please feel free to contact us by email at [email protected]

All the information on this website – https://skydevops.co.in – is published in good faith and for general information purpose only. SKYDEVOPS does not make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this website (skydevops), is strictly at your own risk.
SKYDEVOPS will not be liable for any losses and/or damages in connection with the use of our website.

From our website, you can visit other websites by following hyperlinks to such external sites. While we strive to provide only quality links to useful and ethical websites, we have no control over the content and nature of these sites. These links to other websites do not imply a recommendation for all the content found on these sites. Site owners and content may change without notice and may occur before we have the opportunity to remove a link which may have gone ‘bad’.

Please be also aware that when you leave our website, other sites may have different privacy policies and terms which are beyond our control. Please be sure to check the Privacy Policies of these sites as well as their “Terms of Service” before engaging in any business or uploading any information.

~ Consent ~

By using our website, you hereby consent to our disclaimer and agree to its terms.

~ Update ~

Should we update, amend or make any changes to this document, those changes will be prominently posted here.

-== & ==-

Guide:

Following is the Powershell script that will automate the process of uploading and install AEM package to Author Instance. The uploaded package will be replicated to publish instances using cURL. Following are the parameters,

param(
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$CQ_USER="admin",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$CQ_PASS="admin",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$AEMPORT="4502",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$HOSTNAME="localhost",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$PKGNAME="aemdev.ui.apps-1.0-SNAPSHOT.zip",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$PKGPATH="C:UsersSKYDEVOPSDocumentsAEMMVNaemdevui.appstarget${PKGNAME}",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$GCURL="http://${HOSTNAME}:${AEMPORT}/crx/packmgr/service.jsp",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$RCURL="http://${HOSTNAME}:${AEMPORT}/crx/packmgr/service/script.html/etc/packages/aemdev/${PKGNAME}?cmd=replicate",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$CURLEXE="C:toolscurl761bincurl.exe"
)

Following is the cURL command that will Install Package on AEM instance, which needs username and password to authenticate package installation, also path to the package that needs to be installed

Write-Output "Installing APPS Package"
cmd.exe /c $CURLEXE -u "${CQ_USER}:${CQ_PASS}" -F file=@"$PKGPATH" -F name="AEMDEV" -F force=true -F install=true "$GCURL" | Out-Null
Write-Output "Package Installation Complete"

Following is the cURL command that will replicate the installed package to all the publishers

Write-Output "Replicating Package"
cmd.exe /c $CURLEXE -u "${CQ_USER}:${CQ_PASS}" -X POST $RCURL
Write-Output "Replication Complete"

Following is the entire script

# Parameters
param(
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$CQ_USER="admin",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$CQ_PASS="admin",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$AEMPORT="4502",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$HOSTNAME="localhost",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$PKGNAME="aemdev.ui.apps-1.0-SNAPSHOT.zip",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$PKGPATH="C:UsersSKYDEVOPSDocumentsAEMMVNaemdevui.appstarget${PKGNAME}",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$GCURL="http://${HOSTNAME}:${AEMPORT}/crx/packmgr/service.jsp",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$RCURL="http://${HOSTNAME}:${AEMPORT}/crx/packmgr/service/script.html/etc/packages/aemdev/${PKGNAME}?cmd=replicate",
[String][parameter(Mandatory=$False,ValueFromPipeline=$False)]$CURLEXE="C:toolscurl761bincurl.exe"
)

# Installing Packages
Write-Output "Installing APPS Package"
cmd.exe /c $CURLEXE -u "${CQ_USER}:${CQ_PASS}" -F file=@"$PKGPATH" -F name="AEMDEV" -F force=true -F install=true "$GCURL" | Out-Null
Write-Output "Package Installation Complete"

# Replicating package
Write-Output "Replicating Package"
cmd.exe /c $CURLEXE -u "${CQ_USER}:${CQ_PASS}" -X POST $RCURL
Write-Output "Replication Complete"

Shashi View All

A passionate devops and automation engineer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: