kwc.org Photos Spare Cycles MythBusters

Python script for Hudson API

Update: please use python-jenkins instead, which is the new-and-improved version below (and available via PyPI and in Ubuntu Oneiric).

We use Hudson to do our continuous integration -- anything from building and tests to creating documentation. It's been a fairly versatile tool for us and I highly recommend it.

I was a bit surprised to find that there were no Python scripts on the web for using Hudson's programmatic API. I ended up writing one and I'm posting it here for others to use to save themselves time. As good as Hudson is, the programmatic API is not well-documented, and there are also some annoyances like non-HTTP-compliant authentication that require minor workarounds.

We're now using this script heavily to make Hudson even more versatile: programatically creating jobs, chaining jobs, etc... We're now able to test at a much finer grain, which has led to better testing.

All the code I do for work is BSD, so enjoy:

https://code.ros.org/svn/ros/stacks/ros_release/trunk/hudson/src/hudson.py

Comments (7)

Eric:

Question. But first, thanks for the post. I have had much troble authenticating with the hudson server. Now for my question. How would one download the config.xml for a job. I would like to download the config.XML, tweak it and repost, or create a variant of the config.XML in a new job.

Eric

Ken:

Hi Eric,

You can just add "config.xml" to any job URL to download the config.XML. The standard urllib/urllib2 libraries in Python should work.

- Ken

Petr:

Hello,
thx for hudson.py, I can start building job with it :)

but How can I find the results for specific build run?

kwc Author Profile Page:

Hi Petr,

As far as I know, the only way to get results for a build run is to go to the Hudson web page. The API doesn't let me access the specific build job that is run.

cheers,
Ken

ram:

Hi;
Thanks for the script.
When I tried to create job, I keep getting Http Error 500. But I can query existing job information. The exception message from hudson.jar file is not that helpfull in debugging it.

Just wondering if you have seen this kind of issue before

regards
ram

kwc Author Profile Page:

Sorry, haven't seen that before. The API is pretty hard to debug when things are not working correctly.

James Page:

Hi Ken

This is a great bit of python - it's proven invaluable in a number of projects involving Jenkins that I've implemented.

I've added a few additions to the API myself to provide management of slave nodes.

I'd really like to develop the API further and package it properly for Ubuntu/Debian; would you have any objection and would you like to collaborate on this? Ideally we would set it up as a project on a public VCS somewhere and take it from there.

Let me know

Cheers

James

tags.

related entries.

what is this?

This page contains a single entry from kwc blog posted on September 10, 2010 4:10 PM.

The previous post was Our robot fetches beer!.

The next post is Hacks with ROS: rosproxy.

Current entries can be found on the main page.