jenkins_api_client icon indicating copy to clipboard operation
jenkins_api_client copied to clipboard

get_current_build_number returns current-1 when build is pending

Open izaac opened this issue 8 years ago • 0 comments

The use case: A jenkins slave is offline then using the API I trigger a build in a job then the build is marked as pending and queued somehow with a new build number at least in the UI.

However using the API client I can only get the previous (not pending) build. Is it there any workaround for this scenario?

If I use:

@client.job.abort(job_name, @client.job.get_current_build_number(job_name)+1) 

I got:

/ruby-2.3.1/gems/jenkins_api_client-1.4.3/lib/jenkins_api_client/client.rb:786:in `handle_exception': Requested component is not found on the Jenkins CI server. (JenkinsApi::Exceptions::NotFound)
from /ruby-2.3.1/gems/jenkins_api_client-1.4.3/lib/jenkins_api_client/client.rb:377:in `api_get_request'
from /ruby-2.3.1/gems/jenkins_api_client-1.4.3/lib/jenkins_api_client/job.rb:524:in `stop_build'

Thanks.

izaac avatar Jun 17 '16 17:06 izaac