Follow Us

We use cookies to provide you with a better experience. If you continue to use this site, we'll assume you're happy with this. Alternatively, click here to find out how to manage these cookies

hide cookie message


Monitoring the pulse of IT

Opsview Development Team

Grails & Hudson / Jenkins Part 5: Monitoring build status

Article comments

There are a number of ways you can monitor the progress of your Grails build: using the Hudson / Jenkins web app; or leveraging the API: from your IDE, bespoke API clients or even your enterprise monitoring client. We’ll look at all of them here and build a simple Grails taglib to display build status in the ‘Application Status’ panel.

This is the 5th installment in the series, but the first since the announcement of the new project name of Jenkins (see Kohsuke’s post here).

Note: The particular Hudson instance I’ll be using for this post was set up with a single job for my presentation at the London GGUG and has the Green Balls plugin.

Hudson / Jenkins View Plugins
There are several plugins that provide ‘information radiators’ which make very useful wall displays for agile teams.

radiator view

extreme feedback

IDE plugins
For developers, being able to see the build status within the IDE can be very useful (e.g. if deciding whether to check out the HEAD revision on a large project). For Eclipse/STS users they can install the hudson-eclipse plugin from the update site.

The configuration (Window > Preferences > Hudson) is quite straight forward, in this case just the URL, but there is the option to set credentials, polling interval etc.

The plugin adds a build health icon to the status bar and there is also the following view (you can trigger builds too if you have the correct permissions):

The Hudson / Jenkins Jobs API
This is the basis for the examples that follow - we’ll primarily be looking at the restful GET methods that return JSON data.

If you get “http://localhost:8081/api/json” (replacing the hostname & port as appropriate), the JSON response includes a list of jobs e.g.


Note that the ‘blue’ color denotes a successful build - even if you’ve got the ‘Green balls’ plugin installed.

If you get “http://localhost:8081/job/GGUG_trunk/api/json” (replacing hostname, port & job name as appropriate), the JSON response includes:


The API has built in documentation see e.g. http://localhost:8081/api/? and http://localhost:8081/job/GGUG_trunk/api/?

Groovy scripts
Now we’ve had a quick introduction to the API, let’s look at two simple cases for a Groovy script: status of all jobs and more information on a specific job.
For simplicity we’ll use the Groovy helper getText() method on - if you’ll need authentication I’d recommend using Apache Commons HTTP Client instead.

Using the top-level API:

Gives the output: GGUG_trunk - blue

Or a for a specific job:

We get the output: GGUG_trunk #33 - blue

Grails taglib
Building on what we’ve just achieved (but replacing json.simple with the Grails helper classes), we can display this information in our Grails application (again see caveat about authentication).

This can now be included in the grails-app/views/index.gsp

<h1>Application Status</h1>
<li>App version: <g:meta name="app.version"></g:meta></li>
<li>Latest CI build: <g:buildInfo server="http://localhost:8081" job="GGUG_trunk"/></li>
<li>Grails version: <g:meta name="app.grails.version"></g:meta></li>

And in action:

Monitoring tools
You may also want to incorporate your application build status into your enterprise monitoring so you can have a view across the whole piece, i.e. live, staging, test & development.

Opsview has a service check that I contributed to allow monitoring of Hudson / Jenkins jobs as part of the centralised enterprise monitoring. The Opsview team use this to monitor their own jobs that test the Opsview check ins.

check_hudson_job is a Perl script that uses the JSON job API, the necessary service check arguments are URL, job name, username, password.

Output is provided in standard Nagios plugin format, but the unknown status code is returned if a build is in progress (e.g. the color contains ‘blinking’).

That concludes this series of Grails & Hudson (Jenkins) posts for the time being - hopefully you’ve found it useful as we’ve covered enough to get your Grails projects nicely automated:

Part 1 - CodeNarc integration
Part 2 - back to basics with setting up Hudson / Jenkins for Grails
Part 3 - automated testing of your Grails build
Part 4 - automated deployment of war files


More from Techworld

More relevant IT news


Send to a friend

Email this article to a friend or colleague:

PLEASE NOTE: Your name is used only to let the recipient know who sent the story, and in case of transmission error. Both your name and the recipient's name and address will not be used for any other purpose.

Techworld White Papers

Choose – and Choose Wisely – the Right MSP for Your SMB

End users need a technology partner that provides transparency, enables productivity, delivers...

Download Whitepaper

10 Effective Habits of Indispensable IT Departments

It’s no secret that responsibilities are growing while budgets continue to shrink. Download this...

Download Whitepaper

Gartner Magic Quadrant for Enterprise Information Archiving

Enterprise information archiving is contributing to organisational needs for e-discovery and...

Download Whitepaper

Advancing the state of virtualised backups

Dell Software’s vRanger is a veteran of the virtualisation specific backup market. It was the...

Download Whitepaper

Techworld UK - Technology - Business

Innovation, productivity, agility and profit

Watch this on demand webinar which explores IT innovation, managed print services and business agility.

Techworld Mobile Site

Access Techworld's content on the move

Get the latest news, product reviews and downloads on your mobile device with Techworld's mobile site.

Find out more...

From Wow to How : Making mobile and cloud work for you

On demand Biztech Briefing - Learn how to effectively deliver mobile work styles and cloud services together.

Watch now...

Site Map

* *