12 Apr 2010 Hudson SiteMonitor Plugin and JSLint Violations Support
Late last December, Shine allowed me to spend a couple of days working on some Hudson contributions. I was planning to finish 3-4 plugins, but used up too much time trying various approaches and testing various scenarios. I actually ended up with unfinished implementations back then.
Fast forward to last week, I finally managed to spend a little bit of my own time to finish the plugin(s), and I also accidentally found a bug with Recorder#perform’s return value being ignored from build status determination. Contacted the dev list and Kohsuke has since fixed it in r29836, the fix will be included in Hudson 1.354.
The first plugin I worked on was SiteMonitor Plugin, it’s basically used for monitoring a web site’s up/down status. At work we used to do this by using Ant Conditions Task, I know other people who use wget and various tools to achieve the same result. I just thought it would be much simpler for a Hudson user to be able to install a plugin and add some URLs to monitor without the need to implement any script.
Here’s how SiteMonitor Plugin looks like:
This plugin is still at an early stage and currently only reports response code and up/down status of a web site. It doesn’t have any roadmap per se, but I think future versions of the plugin should have more Pingdom-like features and reports. If you have any request or suggestion, feel free to leave a comment on this blog or raise a JIRA issue and assign it to me.
The rest of my December effort went to JSLint reporting, which ended up as such a simple enhancement to Violations Plugin. It was initially implemented as a standalone plugin, first, it attempted to include a simple Java wrapper for JSLint, a parser for JSLint’s text output, and a report generator. The initial implementation was ditched when I found out that there’s already jslint4java.
So I decided to leave the JSLint handling up to the project being built itself, and the plugin implementation only takes care of output parsing (jslint4java provides a nice XML output on top of JSLint’s default text output) and generating a report page. I used Checkstyle Plugin as a base for my implementation. But this effort was also then scrapped after I found out that Violations Plugin already provides all the groundwork necessary for code violations (duh!) reporting.
Adding JSLint as another type of violations was way too easy in Violations Plugin.
Here’s how JSLint report looks like:
All in all, Hudson’s large array of plugins is a proof of how extensible it is as a platform. Creating new plugins isn’t that hard and Hudson API is quite pleasant to work with. I hope these two little contributions could be useful for someone out there.