Running Groovy scripts through Maven

This recipe describes how to use the gmaven plugin ( to run Groovy scripts.

The ability to run Groovy scripts in builds allows you to consistently use one scripting language in Maven and Jenkins. Groovy can be run in any Maven phase. Maven can execute the Groovy source code from within the build file, at another file location, or from a remote web server.


Maintainability of scripting

For later re-use, consider centralizing your Groovy code outside the build files.

Getting ready

Create the directory ch3.building_software/running_groovy.

How to do it...

  1. Add the following fragment just before the</project> tag within your template file (mentioned in the introduction), ...

Get Jenkins Continuous Integration Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.