Hudson Ruby Gem

Today I created my first Ruby gem and published it on Gemcutter: hudson-remote-api.
The source code is available on GitHub: http://github.com/Druwerd/hudson-remote-api

This gem allows you to interact with Hudson’s remote access api using Ruby. So far the features include triggering builds, disabling jobs, copying jobs, updating job configuration and more.

I have used this set of scripts to automated many tasks with Hudson. Here are some examples of what you can do.

Get a list of all Hudson jobs currently building:

Hudson::Job.list_active

List all Hudson jobs in the build queue:

Hudson::BuildQueue.list

Get the next build number for a Hudson job:

job = Hudson::Job.new('jobname')
job.next_build_number

Trigger a build:

job = Hudson::Job.new('jobname')
job.build

Create a new Hudson job to build from an SVN branch:

job1 = Hudson::Job.new('jobname')
job2 = job1.copy
job2.repository_url = job2.repository_url.sub("trunk", "branches")
Advertisements
Tagged with: , , , ,
Posted in hudson, ruby

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: