Skip to content
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

Allowing selection of jobs in folders #56

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/jenkins_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_connection


def get_jobs_list
jenkins_client.get_jobs_list
jenkins_client.get_available_jobs
end


Expand Down
27 changes: 26 additions & 1 deletion app/services/jenkins_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_connection
test[:errors] = []

begin
test[:jobs_count] = connection.job.list_all.size
test[:jobs_count] = get_available_jobs.size
rescue => e
test[:jobs_count] = 0
test[:errors] << e.message
Expand All @@ -52,4 +52,29 @@ def number_of_builds_for(job_name)
connection.job.list_details(job_name)['builds'].size rescue 0
end


def get_available_jobs
filter_job_names(search_in_depth).sort
end


def filter_job_names(list)
names = []
list.each { |item|
if item.key?("jobs")
filter_job_names(item["jobs"]).map { |child|
names << item["name"] + "/job/" + child
}
else
names << item["name"]
end
}
return names
end


def search_in_depth
connection.api_get_request("", "tree=jobs[name,jobs[name,jobs[name]]]")["jobs"]
end

end