Follow Us

Monitoring the pulse of IT

Grails & Hudson / Jenkins Part 5: Monitoring build status



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.

e.g.
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.

"jobs":[{"name":"GGUG_trunk","url":"http://localhost:8081/job/GGUG_trunk/","color":"blue"}],

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:

"displayName":"GGUG_trunk",
"name":"GGUG_trunk",
"color":"blue",
"lastBuild":{"number":33,"url":"http://localhost:8081/job/GGUG_trunk/33/"},

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 java.net.URL - 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
e.g.

<h1>Application Status</h1>
<ul>
<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

Tags: grails, hudson, opsview

RSSSubscribe to this blog

More from Techworld

More relevant IT news

Contact Us

For editorial queries:
Mike Simons Mike_Simons@idg.co.uk

For website issues:
Email webmaster@techworld.com

For commercial queries
Russell Kearney russell_kearney@idg.co.uk


For more contact details click here.


Email this to a friend

* indicates mandatory field





Techworld White Papers

Optimising data protection for virtual environments

VM environments require the same level of data protection as does the physical server environment. Companies may use data protection tools built for the physical environment in the virtual world, but this has serious disadvantages.

Download Whitepaper

PCI Compliance: Are UK businesses ready?

Exploring the results of a recent survey, including: ? Levels of understanding of the standard ? Current perceptions of actual compliance status ? Attitudes toward addressing compliance

Download Whitepaper

Mobility Management for Dummies

Your complete guide to managing and securing mobile devices such as laptops and smartphones.

Download Whitepaper

Magic Quadrant for midrange and high-end NAS solutions

It is difficult to find one midrange or high-end NAS product that can cater to all needs. File systems embedded in NAS are often designed to solve one major pain point, with additional features being added later to broaden use cases and benefits.

Download Whitepaper

Techworld UK - Technology - Business

Oracle Video

Enabling agile and intelligent businesses

 Changing markets, competitive pressures and evolving customer needs are placing increasing pressure on IT to deliver greater flexibility and speed. Explore truly flexible SOA foundations with this Oracle video.

Watch
COLT White Paper

IT Misuse Survey

Complete this survey and you could win a Nexus One

Techworld are running a short survey to discover how UK businesses are managing Internet and email misuse in the Enterprise.

Complete Survey

Complete our survey and you could win a Sony E-book Reader.
Techworld have teamed up with HP to compile a survey relating to server virtualisation. Complete the short survey and you could be the lucky winner of a Sony E-book reader.

Complete the survey here

Site Map

Test