Tuesday, August 10, 2010

Using Hudson for Unusual Tasks

Martin Fowler wrote, "Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible. Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly." (http://martinfowler.com/articles/continuousIntegration.html)

Hudson is a continuous integration solution. "In a nutshell, Hudson provides an easy-to-use so-called continuous integration system, making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build." (http://wiki.hudson-ci.org/display/HUDSON/Meet+Hudson)

I found somewhat unusual uses for Hudson.

Ryzing follows a standard development setup with a set of servers (or chain) for each stage of development: Alpha, Quality Assurance (or QA), and Production. We chose the Amazon Cloud to host the servers. Three chains mean three separate databases running on three separate database servers. I firmly believe in automating routine tasks. A daily backup is definitely a routine task. My solution to automating the backups was to use our Hudson server.

The Ryzing applications use PostgreSQL as the database server. I installed the full PostgreSQL tool set on the Windows 2008 server dedicated to running Hudson (http://www.postgresql.org/download/windows). I made sure that both the Windows firewall and the Amazon security zones allowed the build server to talk to the database servers in the Alpha, QA, and Production chains.

The project in Hudson is simple. The build process uses a Windows batch command. Below are the commands I used.

"C:\Program Files\PostgreSQL\8.4\bin\pg_dump.exe" --no-password --file=DATABASENAME.backup --format=c --host=HOSTNAME --port=HOSTPORT -U USERNAME DATABASENAME

You will need to set the appropriate password, database name, host name, user name, and host port. I checked a Post-Build action to Archive the Artifacts telling Hudson to archive DATABASENAME.backup. I selected the build trigger of building periodically. Each morning the build server runs the backup on each database.

Hudson provides a convenient place to store the database backups along with all our software builds.

1 comment:

倪平 said...