2

I have been using package manager commands to deploy AEM packages to author nodes as part of a Continuous Deployment pipeline. I am now extending this to deploy directly to publish nodes. I need (according to the node owners) to do this slightly differently.

Since I am programming these interactions and have to support a whole bunch of nodes, I was wondering if the pipeline can call some endpoint which is somehow unique to an author or a publish so I can detect which was selected this time around?

For context here's an example of the calls I am making.

curl -u admin:admin -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/samplepackage.zip?cmd=uninstall

I regret I am not (yet) that familiar with AEM beyond the package manager API. I got this example from AEM CQ5 Tutorials but have found nothing else there directly useful, perhaps because I am unsure whcih REST APIs relate to which kinds of node.

If I could find a cheap and harmless GET that is unique to one or the other I would be sorted.

Simon Gibbs
  • 4,737
  • 6
  • 50
  • 80
  • You could get `http://author.local.telegraph.co.uk:4502/system/console/status-slingsettings.json` to check the runmodes but you'll need to provide credentials for the system console. Why do you need to do that anyway? When you deploy an AEM instance, you set it up as an author or a publisher and that can't be changed later. In order to execute your scripts against a number of AEM instances, you need a list of those anyway. The list could contain the necessary metadata (whether an instance is an AEM Author or Publish) – toniedzwiedz Aug 24 '16 at 15:29
  • The reason is economic. I am not scripting and the pipeline is actually a complex system which supports N deployment technologies of which AEM is just one. Ideally the system could store some extra data like node type, but it is potentially cheaper to ask the endpoint. It is reasonably likely we will add a feature to store node type, or we might go this way, depending on the answers we get. – Simon Gibbs Aug 25 '16 at 09:18

2 Answers2

1

I have used this SlingSettings API to get sling runmodes using which you can determine whether it is author or publish. It's a pretty lightweight call.

http(s):<host:port>/system/console/status-slingsettings.json

Abhishek
  • 1,130
  • 1
  • 12
  • 25
0

AEM provides runmode agnostic way of deploying packages unless you have different deployments going to those instances.

In most of the general use-cases the deployment package is same for author and publish and so is the deployment path, all that changes is the host. We build a separate pom project for deployment purposes, which can directly push any kind of package to any node specified as CI Job param. In our case we used it only for deploying a complete application package.

POM looks something like this -

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>cms-parent</artifactId>
        <groupId>com.myproject.cms</groupId>
        <version>1.0.2</version>
    </parent>

    <artifactId>cms-deploy</artifactId>
    <groupId>com.myproject.cms.deploy</groupId>
    <packaging>pom</packaging>
    <version>1.0.0</version>
    <name>
        AEM :: Deploy
    </name>

    <properties>
        <app.cms.myproject.complete.version>1.0.0-SNAPSHOT</app.cms.myproject.complete.version>
    </properties>

    <build>
        <plugins>
            <!-- additionally deploy three further content-packages which are not part of the complete-package -->
            <plugin>
                <groupId>com.day.jcr.vault</groupId>
                <artifactId>content-package-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <!-- override the default execution defined in the cq-parent by binding it to some invalid phase -->
                        <id>default-package</id>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <phase>foobar</phase>
                    </execution>
                    <execution>
                        <!-- override the default execution for install-package, which is called whenever you call deploy -->
                        <id>install-package</id>
                        <goals>
                            <goal>install</goal>
                        </goals>
                        <phase>foobar</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>

        <profile>
            <id>install-myproject-complete</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>content-package-maven-plugin</artifactId>
                        <groupId>com.day.jcr.vault</groupId>
                        <executions>
                            <!-- deploy the scripts and classes (part of the release) -->
                            <execution>
                                <id>install-myproject-complete</id>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                                <configuration>
                                    <artifactId>myproject-complete</artifactId>
                                    <groupId>com.myproject.cms.msites</groupId>
                                    <version>${app.cms.myproject.complete.version}</version>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

The you could create a maven project in CI (i am referring to Jenkins as CI, you could adapt to your server) and set it up as a parameterized build that accepts host and deployment version Build Params

Next would be to configure the Source Code Management to point to above pom project in your SCM and configure maven build step -

enter image description here

In goals and options specify - For Author deployment -

-U clean install -Pinstall-myproject-complete -Dcrx.host=${host}-author.mysite.com -Dcrx.port=4502 -e -Dapp.cms.myproject.complete.version=${version}

For publish deployment -

-U clean install -Pinstall-myproject-complete -Dcrx.host=${host}-publish.mysite.com -Dcrx.port=4503 -e -Dapp.cms.myproject.complete.version=${version}

This is the base configuration, you could further customize it to accept either the entire node_name/ip along with port information to keep a single pipleline for deployment

Ameesh Trikha
  • 1,652
  • 2
  • 12
  • 18
  • Thanks for the detailed reply but the particulars of the deployment process *at my client's institution* are different for each node type. Sorry. – Simon Gibbs Aug 25 '16 at 14:10