Hi guys,
I'd like to stop a build which is currently in queue.
based on jenkins REST API, I found this info:
Now, I'd rather of course use the jenkins_api_client in order to implement this.
I noticed that there are couple that aren't clear to me, mainly with stop_build method:
1.
this function basically does it all. except that it can't handle build which aren't currently building.
the actual method supports it (with build_number input other that 0), but lines 448-450 will terminate as the build is queuing rather then building.
2. how can I get my build number?
Keeping in mind, that queued build build number is changing in case of prior build cancellation, and therefore nor permanent.
So, I'm searching for a way to figure out my build_number based on other test parameters.
(to start with, I assigned to each build a unique number as a parameter, to hopefully there's a place with both numbers).
(Object) stop_build(job_name, build_number = 0)
Stops a running build of a job This method will stop the current/most recent build if no build number is specified. The build will be stopped only if it was in 'running' state.
Parameters:
- job_name (String)
- build_number (Number) (defaults to: 0)
[Hide source]442
443
444
445
446
447
448
449
450
451
452
453 | # File 'lib/jenkins_api_client/job.rb', line 442
def stop_build(job_name, build_number = 0)
build_number = get_current_build_number(job_name) if build_number == 0
raise "No builds for #{job_name}" unless build_number
@logger.info "Stopping job '#{job_name}' Build ##{build_number}"
# Check and see if the build is running
is_building = @client.api_get_request(
"/job/#{job_name}/#{build_number}"
)["building"]
if is_building
@client.api_post_request("/job/#{job_name}/#{build_number}/stop")
end
end |
and I found there some representations related to "item" path- AKA task_id/ task name
there are plenty of methods that using task_name/ task_id to reveal details on the build (maybe build number?)
But I can't figure out how exactly should I approach and fine out my build task_id/task_name
thanks a lot!
Dan