Sunday, January 13, 2013

How to publish Code / Component in CQ

Use Case: You want to publish your code to publish instance.

Solution: There are multiple ways to do this,

1) Package Manager (Recommended):

  • Go to package manager through <HOST>:<PORT>/crx/packmgr/index.jsp
  • Click on Create package. Give Package name and filter

  • Once package is created, Click on Edit, Click on filter and select filter for your code. Usually it is /apps/<Your code>, /etc/design/<your code>, Some custom code.

  • Then click ok and click on build package.
  • Once package is build you can click on more and then replicate.

  • If you don't have replicate option (If you are using CQ version less than 5.5), Then download that package and install it in all publish instance.
  • You can also use curl command to install package on publish instance
  • Curl command will look like this 
curl -f -u <USERNAME>:<PASSWORD> -F name=<Package Name> -F file=@<Location of downloaded file in file system> -F install=true http://<HOST>:<PORT>/crx/packmgr/service.jsp"/>

  • You can manage each package
  • Can uninstall package to go to previous revision
  • Can migrate package from any environment to any environment
  • Manually build package every time

2) Using Tree activation
  • Go to welcome page -> tools -> replication -> Activate Tree -> double click

  • Select root path as your code path. First select /apps/<Your code> then /etc/design/<Your Design>

  • Then click on Activate
  • Simple. You just have to select tree you want to activate
  • Version not supported, Hence you can not revert back to previous code.

3) Using file System

  • You can also put your code package (Created using package manager in author) to install directory under /crx-quickstart (If directory does not exist then create one)
  • This method will require restart of your CQ instance and usually not recommended.
  • Useful if you have very large package
  • Delay installation till restart. Usually helpful in production deployment.
  • Restart required
  • package needs to be kept on each publish instance manually.

4) Using CRXDE light (For Only one file change, Only available after CQ5.5)

  • If you want to do some quick developement in your local then you can use CRXDE to replicate code as well. 

  • Useful of you are doing local development and quickly change result of "Single" file in publish.
  • Simple
  • You can activate only single file
  • No versioning and no revert back

5) Using build script (Recommended in Project)

You can use either Maven or Ant or any build system to build and install code to any environment you want.

If you are using Maven then you can do something like this

If you are using Ant then you can do something like this

<target name="package-apps-etc">
    <mkdir dir="${target.dir}"/>
<zip destfile="${target.dir}/${}">
    <zipfileset dir="${home.dir}/jcr_root" excludes="**/.vlt,**/*.svn" prefix="jcr_root"/>
    <zipfileset dir="${home.dir}/META-INF" prefix="META-INF"/>

<target name="local-install-apps-etc-publish" depends="package-apps-etc">
<exec executable="curl" failonerror="true">
  <arg line="-f -u admin:admin -F name=citrix-package -F file=@target/ -F install=true http://localhost:4503/crx/packmgr/service.jsp"/>

You can automate these script using any Continuous build system (Bamboo or Jenkins or any)

  • Structured
  • Can modify based on need
  • Complex
  • May need additional resource

Each project has different requirement, Hence way package deployed is also different. Any suggestion or new way to do this is welcome. 



  1. I’ll bookmark your web site and take the more feeds additionally…I’m happy to locate a lot of helpful information right here within the post. Thank you for sharing…

  2. Sir, have you written any blog through which i can apply a custom workflow in my website ??

    1. Rahul,

      I am not sure what do you mean by applying custom workflow ? Is it custom workflow created in CQ you want to migrate ?


  3. actually ,i just create a workflow model but i just copy paste the code didn't understand it. i want to understand how it works. i prefer this link

    1. Rahul,

      Not clear with your question. What is your requirement ?


  4. Hi yogesh i need some help .Even after i turned on the names manglig option . the images are not getting cached in _JCR_content/ . i mean there is no folder created for jcr:content under dam !what could be the possible case ? i am using cq 5.6

    1. M.S,

      _jcr_root folder for DAM only get created if you are accessing renditions for a image AND request for rendition happen before actual image request. To test do this, Clear your dispatcher cache and then access rendition for the image and after that only access original image.

      Hope it make sense. Usually access to image rendition should always be done through thumbnail servlet.


  5. Yogesh,
    I find this helpful.... one quick question
    Is there a adobe reference that you can point me to mentioning that point # 5 "Using build script" is Recommended in Project


    1. Hello Kasi,

      Please check