arangamani/jenkins_api_client — pull request #106 by dougforpres (2013-10-10 21:43:28+00:00)
Title: Build version number support on pre-post 1.519 Jenkins, plus callbacks while waiting

Hi

This is a port of some code we were using internally to get a better result when waiting for a queued build to start.

The prior 'wait for build number' would work only on 1.519+ versions of Jenkins, and would silently block while it was waiting. Our need was for a more 'chatty' wait, so we added the (optional) callbacks.

This push includes code to auto pull the Jenkins and Hudson version numbers on every request, so additional requests do not need to be made to determine version number. There are also some utility methods to compare two version strings and return -1, 0, +1 based on older, same, newer.

The build method still supports the previous true/false for param 3, but now accepts a hash of options.
The options include:
- how long to wait for build to start (if not specified, same as old 'false' param) - default OFF
- whether to attempt cancel of queued job if timeout occurs - default NO
- how often to poll - default 2 seconds
- callback for wait progress - default nil
- callback for 'build' start/fail - default nil

Returns same as it used to, and raises Timeout::Error as it used to.

Determines whether it can use 'queue' object to monitor job-wait, or whether it has to use older 'get job status' method (which raises NotFound if job hasn't started) automatically, and behavior is identical regardless of the Jenkins version.

caveat: the 'cancel' option has no effect on older Jenkins.

unit/func tests included

Regards
Doug