wttech / gradle-aem-plugin

Swiss army knife for Adobe Experience Manager related automation. Environment setup & incremental AEM application build which takes seconds, not minutes.
https://tech.cognifide.com/tag/gradle-aem-plugin
Apache License 2.0
158 stars 32 forks source link

Automated deployment quick fixes mechanism #89

Closed pun-ky closed 5 years ago

pun-ky commented 6 years ago

Basing on fact, that there is ability to execute any Groovy Script code via simple HTTP POST request, imagine:

aemCall {

    // sh gradlew aemCall -Paem.call.name=restart-scene7

    call "restart-scene7" { instance ->
        path = "/bin/groovyconsole/post.json"
        method = "POST"
        params = [
            "script": readFile("scripts/restart-scene7-bundle.groovy")
        ]
        headers = [
            "Referer": "${instance.url}/etc/groovyconsole.html",
            "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        ]
    }

    groovyScript "restart-scene7-bundle" // same as above using built-in helper; this even could be skipped, because script could be find by convention

    // sh gradlew aemCall -Paem.call.name=remove-my-node
    // other built-in helper

    groovyCode "remove-my-node", """
        def myNode = resourceResolver.getResource("/tmp/my-node")
        resourceResolver.delete(myNode)
        resourceResolver.commit()

    """

}

Groovy script related API will require Groovy Console CRX package installed on instance (for instance using aemSatisfy) https://github.com/OlsonDigital/aem-groovy-console .

pun-ky commented 6 years ago

this calls could be treated as migrations, so that on repository after executing each call we could save that info and later reuse to prevent executing migration again

pun-ky commented 6 years ago

instead of using dynamically typed groovy it would be better to use *.kts scripts and introducing Kotlin Scripting Console which will work regardless AEM version / Groovy version is very closely bound to AEM version so using it will require regular plugin update to match current AEM version which is not good for that mechanism to work for long time...

pun-ky commented 6 years ago

Imagine chef like approach

/apps/example/provision/scripts/[cqsm.kts,migration.kts,clean.kts]

aemProvision { // order make precedence as in chef cookbook run lists
    script "cqsm'
    script "migration', {
        runStrategy = 'ONCE'
    }
    httpRequest { client ->
       client.get("/system/console/bundles/restart/[symbolic-name]") // pseudocode
    }
    script "clean", {
        runStrategy { Calendar.getInstance().dayOfWeek == 1 } 
    }
}

then just imagine

sh gradlew aemBuild aemAwait aemProvision ... so powerful, fully automated (no chef / SE help required)

pun-ky commented 5 years ago

partially addressed by custom tasks using aem.sync{ it.get("/bin/servlet/xxx) } ; will be improved within 6.0.0

pun-ky commented 5 years ago

methods to be added to InstanceSync

pun-ky commented 5 years ago

only left

[start/stop/restart]Bundle(symbolicName: String)
[start/stop/restart]Component(pid: String)
pun-ky commented 5 years ago

implemented as

image

pun-ky commented 5 years ago

to be released within 6.0.0