At work I recently created a Groovy automation script that parsed FTP log files and generated a web based report. This script was then added as a scheduled job in the open-source Jenkins continuous integration server. Groovy support is built in to Jenkins.
Groovy certainly made this very easy (from a Java perspective). The script used the Groovy GDK (extensions to Java’s classes) and iteration via closures, first of the target folder, and then on each file’s lines. A regexp was used to grab the info. Finally a Groovy Builder was used to create the HTML page.
After looking at the solution I thought it could be simplified if there was support for this pattern in some kind of template or API. A sample approach is shown below. Of course, this is only applicable for line oriented data files. When data spans multiple lines one must use more stateful approaches or parsing tools.
- Sep 23, 2013: Version of this code at a Gist here.
- Sep 23, 2013: Changed method signature of gather at folder. But, perhaps, the gather at file level does not need the filter closure.
- Use Groovy to recurse folders and create files via template
- Groovy template fails if language keywords used
- Jenkins CI Server is great
- Remove duplicate lines using Groovy