1

I am using the grails-cdn-asset-pipline plugin. I've gone through the installation and configuration steps on GitHub and I reach the usage section which says

Add this command to your build process (usually before war generation and deployment).

// If all the settings are defined in your Config.groovy
grails asset-cdn-push
// Or
grails asset-cdn-push --provider=S3 --directory=my-bucket --gzip=true --storage-path=some-prefix --expires=365 --region=eu-west-1 --access-key=$MY_S3_ACCESS_KEY --secret-key=$MY_S3_SECRET_KEY

Where in my project do I put this command?

Is it something that I can do within the context of my project, or do I need to keep it separate in another build process and run it in an environment like Jenkins?

In _Events.groovy, I tried to invoke the script in the eventCreateWarStart, but I am having no luck there. (Code taken from this question)

eventCreateWarStart = { warName, stagingDir ->
    def pluginManager = PluginManagerHolder.pluginManager
    def plugin = pluginManager.getGrailsPlugin("cdn-asset-pipline")
    def pluginDir = plugin.descriptor.file.parentFile

    Map<String, String> env = System.getenv()
    final processBuilder = new ProcessBuilder()
    processBuilder.directory(new File("${cdnAssetPipelinePluginDir}/scripts"))
    processBuilder.command([env['GRAILS_HOME']+"/bin/grails","cdn-asset-push"])
    println processBuilder.directory()
    Process proc = processBuilder.start()
    proc.consumeProcessOutput(out, err)

    proc.waitFor()
}

This link explains the run-script functionality which was merged into Grails 1.3.6. But I ran into the same problem of not knowing where to run it automatically.

Community
  • 1
  • 1
Kirk Backus
  • 4,776
  • 4
  • 32
  • 52
  • 1
    have you tried this in your create event: http://grails.github.io/grails-doc/latest/guide/commandLine.html#reusingGrailsScripts -- the name would be assetCdnPush (https://github.com/agorapulse/grails-cdn-asset-pipeline/blob/master/scripts/AssetCdnPush.groovy); i don't know out of my head if this is supposed to work for the events; otherwise try to create a new script e.g. warAndCdnPush and just call the other two there. – cfrick Apr 01 '15 at 15:53

0 Answers0