Continuous Integration with Grails and Jenkins
This article addresses how to create a Grails build with Jenkins and the Grails Wrapper.
WARNING: Using the Grails Wrapper to build a project is significantly slower than using a pre-installed Grails SDK as described in the How to declare a Grails SDK in Jenkins. Details on the Grails Wrapper are available at The Grails Framework - Reference Documentation - Grails Wrapper.
1. Click on Builds
2. Click on Manage Jenkins
3. Click on Manage Plugins
4. Ensure that the Grails plugin is enabled
5. Create a Free Style Job
6. Add a "Build With Grails" step using Grail Wrapper
Warning, using the "Grails Wrapper" to build the application requires the prior installation of this Wrapper (see Grails Documentation > The Wrapper).
7. Add a post build action "Deploy Application"
How to declare a Grails SDK in Jenkins
If you don’t use the Grails Wapper, you will need to declare a Grails SDK in your Jenkins configuration.
1. Click on "Manage Jenkins"
2. Click on "Configure System"
3. Scroll down to Grails and click on "Grails installations…"
4. Declare the Grails SDK with the needed version
My build fails with IOException: Cannot run program "grails"
[grails-petclinic] $ grails clean --non-interactive FATAL: command execution failed java.io.IOException: Cannot run program "grails" (in directory "/scratch/jenkins/workspace/grails-petclinic"): error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... Caused by: java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) ... Build step 'Build With Grails' marked build as failure Finished: FAILURE
You probably configured the Grails build to not use the Grails Wrapper and the local "Grails installation" has a problem or there is no local Grails installation.
Please verify that the Grails SDK you need for your job is properly configured at the Jenkins global configuration level. See How to declare a Grails SDK in Jenkins.
Special thanks to Aurélien Maury from Xebia for his help!
Online version published by CloudBees, Inc.
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Apache, Apache Ant, Apache Maven, Ant and Maven are trademarks of The Apache Software Foundation. Used with permission. No endorsement by The Apache Software Foundation is implied by the use of these marks.
Other names may be trademarks of their respective owners. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and CloudBees was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.