-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build version number support on pre-post 1.519 Jenkins, plus callbacks while waiting #106
Conversation
… add support for version number deconstruction and comparison
…uild-queue progress and optional auto-cancel if build doesn't start within timeout period (for Jenkins post 1.519 release). Retained backward compatibility with previous build method through check of Hash or True/False in 3rd param
That build failure seems outside the scope of my changes |
I know the build failure issue. Don't worry about it. |
# v 1.2 is a lot older than v 1.102 - and simple < > on version | ||
# strings doesn't work so well | ||
def deconstruct_version_string(version) | ||
match = version.match(/^(\d+)\.(\d+)$/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible that people use LTS releases of Jenkins. The recent LTS release for Jenkins is 1.509.4
. In this case this can't match the version correctly. So a patch version should be added to this logic along with major and minor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, was unaware of that - I had taken a quick squiz at the versions and had not seen the 3 parter.
Will definitely fix!
Not trying to rush you or anything, but have you had a chance to take a deeper look at this? |
I was looking at that. When running functional tests the node creation started failing because of a recent change in Jenkins and started thinking whether we need to support all versions of Jenkins or not. I'll keep you posted. |
# successfully removed from build-queue | ||
# | ||
# @return [Integer] build number, or nil if not started (if timeout specified) | ||
# [Response] http response code (per prev. behavior) (no timeout specified) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation of this method doesn't look good when generated with yard. Could you take a look?
I really appreciate your patience 😃 |
Build version number support on pre-post 1.519 Jenkins, plus callbacks while waiting
NameError: undefined local variable or method `expected_build_number' for #<JenkinsApi::Client::Job> from /Users/Sebastian/.rvm/gems/ruby-1.9.3-p327/bundler/gems/jenkins_api_client-98d8f27bc0aa/lib/jenkins_api_client/job.rb:919:in `block in get_build_id_the_old_way' introduced in 94bd8b1 (merged pull request arangamani#106)
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:
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