class LeeroyJenkins::Cli
Public Class Methods
exit_on_failure?()
click to toggle source
exit non-zero on failure github.com/erikhuda/thor/issues/244
# File lib/leeroy_jenkins/cli.rb, line 5 def self.exit_on_failure? true end
Public Instance Methods
append(xml_file_path)
click to toggle source
# File lib/leeroy_jenkins/cli.rb, line 21 def append(xml_file_path) puts update_jobs(read_and_validate_xml_file(xml_file_path), __method__) end
backup(backup_dir)
click to toggle source
# File lib/leeroy_jenkins/cli.rb, line 38 def backup(backup_dir) puts JobBackupper.new(job_names, jenkins_client, backup_dir, options[:threads]).backup(options[:dry_run]) end
delete()
click to toggle source
# File lib/leeroy_jenkins/cli.rb, line 33 def delete puts update_jobs('', __method__) end
replace(xml_file_path)
click to toggle source
# File lib/leeroy_jenkins/cli.rb, line 27 def replace(xml_file_path) puts update_jobs(read_and_validate_xml_file(xml_file_path), __method__) end
restore(backup_dir)
click to toggle source
# File lib/leeroy_jenkins/cli.rb, line 43 def restore(backup_dir) job_restorer = JobRestorer.new(jenkins_client, backup_dir, options[:threads], job_rows, options[:job_regex]) result = options[:dry_run] ? job_restorer.dry_run : job_restorer.restore! puts result end
Private Instance Methods
die(error_message)
click to toggle source
# File lib/leeroy_jenkins/cli.rb, line 82 def die(error_message) error error_message exit 1 end
jenkins_client()
click to toggle source
# File lib/leeroy_jenkins/cli.rb, line 64 def jenkins_client @jenkins_client ||= JenkinsClientBuilder.new( server_url: options[:server_url], username: options[:username], password: options[:password], log_level: options[:jenkins_log_level], log_location: options[:jenkins_log_location] ).build end
job_names()
click to toggle source
# File lib/leeroy_jenkins/cli.rb, line 74 def job_names JobFinder.new(jenkins_client).find_jobs(options[:job_regex], job_rows) end
job_rows()
click to toggle source
# File lib/leeroy_jenkins/cli.rb, line 78 def job_rows options[:jobs] ? File.read(options[:jobs]).split("\n") : [] end
read_and_validate_xml_file(xml_file_path)
click to toggle source
# File lib/leeroy_jenkins/cli.rb, line 52 def read_and_validate_xml_file(xml_file_path) raw_xml_string = File.read(xml_file_path) xml_parse_error = LeeroyJenkins.invalid_xml_document?(raw_xml_string) die("#{xml_file_path} does not contain well-formed XML: #{xml_parse_error}") if xml_parse_error raw_xml_string end
update_jobs(raw_xml_string, command_name)
click to toggle source
# File lib/leeroy_jenkins/cli.rb, line 59 def update_jobs(raw_xml_string, command_name) job_updater = JobUpdater.new(job_names, raw_xml_string, jenkins_client, options[:xpath], command_name, options[:threads]) job_updater.update_jobs(options[:dry_run]) end