Auto-deployment to JBoss with Hudson - it ain’t Rocket Surgery
Posted by: Matt in Software development, Web tools, tags: Hudson, JBoss, Subversion, toolsIt’s fairly common to have your continuous integration tool running on the same machine that has your source code repository. It’s also fairly common to have your development server running on that same machine as well. But what if you don’t?
At my workplace we use Hudson for continuous integration (and anyone who’s read my blog knows I’m a big fan) and Subversion (which is also awesome) for source code management. These both run on the same machine. We also use JBoss as our web/app server, but on different machines, including the web server set up for development testing. We wanted to do automatic deployment to our development JBoss upon successful completion of a build.
One way to do that, of course, is to add a deploy target to your Ant script that copies the packaged .WAR file to the JBoss’s deploy directory; JBoss will see the new file, and automatically deploy it. If your CI server is running on a different machine than your development server, it’s common for those servers to require SSH communications to access them. In this case, a straight <copy> task in Ant won’t do it; Ant 1.6 and later has a <scp> task that can do the job, but since it’s an optional task with library dependancies, you need to make your SSH libraries available on your Ant script’s classpath.
But another alternative is to have Hudson do the work. There is a plugin available for Hudson that does just that - it can copy via SSH your deployable artifact to the server or servers of your choice.
To use the plugin, first download it to some place on your machine, then using the “Manage Plugins” option from Hudson’s system configuration, add the plugin to your Hudson installation.
Once it is installed and Hudson is restarted, go into the global configuration for Hudson and define one or more “SCP repository hosts” - that is, destinations for the SSH copy.

Then on each build job, you have a new option to publish artifacts to your SCP destinations (”repositories”):

The files to upload get copied to your destination. So if you define your SCP repository as your development server, set the source as your build artifact, and set the destination as your deploy directory, you’ll get automatic deployment after every good build, over a secure connection. Voilà
Thanks to the Hudson Wiki for the screenshot graphics!

Entries (RSS)