-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjenkins_api_server_general.rb
executable file
·48 lines (44 loc) · 1.32 KB
/
jenkins_api_server_general.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/ruby193-ruby
require "rubygems"
require "sinatra"
require "sinatra/jsonp"
require 'rack/cache'
require "json"
require 'jenkins_api_client'
require_relative "jenkins_api.rb"
set :server, "webrick"
use Rack::Cache
before do
cache_control :public, :max_age => 60
sleep 2
end
get "/job_info/multi_jobs" do
multi_job_names = []
jobs = []
for i in 0..multi_job_names.length-1
job_name = multi_job_names[i]
job_status = get_current_build_status_for_job(job_name)
job_num = get_current_build_number_for_job(job_name)
job_num = job_num.to_i
job_details = get_job_details(job_name)
downstream_jobs = get_downstream_jobs(job_details)
main_job_hash = {"job_name" => job_name, "job_number" => job_num, "job_status" => job_status}
# put the main job at the front of the array
jobs << downstream_jobs.unshift(main_job_hash)
end
puts jobs
JSONP jobs
end
get "/job_info/all_jobs" do
job_names = get_all_jenkins_jobs
count = job_names.length-1
jobs = []
for i in 0..count
job_status = get_current_build_status_for_job(job_names[i])
job_num = get_current_build_number_for_job(job_names[i])
job_num = job_num.to_i
job_details = get_job_details(job_names[i])
jobs.push({"job_name" => job_names[i], "job_number" => job_num, "job_status" => job_status})
end
JSONP jobs
end