Class: LeeroyJenkins::JobRestorer
- Inherits:
-
Object
- Object
- LeeroyJenkins::JobRestorer
- Defined in:
- lib/leeroy_jenkins/job_restorer.rb
Instance Attribute Summary collapse
-
#backup_dir ⇒ Object
readonly
Returns the value of attribute backup_dir.
-
#jenkins_client ⇒ Object
readonly
Returns the value of attribute jenkins_client.
-
#threads ⇒ Object
readonly
Returns the value of attribute threads.
Instance Method Summary collapse
- #dry_run ⇒ Object
-
#initialize(jenkins_client, backup_dir, threads) ⇒ JobRestorer
constructor
A new instance of JobRestorer.
- #restore! ⇒ Object
Constructor Details
#initialize(jenkins_client, backup_dir, threads) ⇒ JobRestorer
Returns a new instance of JobRestorer.
5 6 7 8 9 |
# File 'lib/leeroy_jenkins/job_restorer.rb', line 5 def initialize(jenkins_client, backup_dir, threads) @jenkins_client = jenkins_client @backup_dir = backup_dir @threads = threads end |
Instance Attribute Details
#backup_dir ⇒ Object (readonly)
Returns the value of attribute backup_dir.
3 4 5 |
# File 'lib/leeroy_jenkins/job_restorer.rb', line 3 def backup_dir @backup_dir end |
#jenkins_client ⇒ Object (readonly)
Returns the value of attribute jenkins_client.
3 4 5 |
# File 'lib/leeroy_jenkins/job_restorer.rb', line 3 def jenkins_client @jenkins_client end |
#threads ⇒ Object (readonly)
Returns the value of attribute threads.
3 4 5 |
# File 'lib/leeroy_jenkins/job_restorer.rb', line 3 def threads @threads end |
Instance Method Details
#dry_run ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/leeroy_jenkins/job_restorer.rb', line 11 def dry_run pairs = Parallel.map(config_xml_file_paths, in_threads: threads) do |xml_path| job_name = File.basename xml_path, '.*' [job_name, File.read(xml_path)] end Hash[pairs] end |
#restore! ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/leeroy_jenkins/job_restorer.rb', line 20 def restore! pairs = Parallel.map(config_xml_file_paths, in_threads: threads) do |xml_path| job_name = File.basename xml_path, '.*' http_status_code = jenkins_client.job.create_or_update job_name, File.read(xml_path) [job_name, http_status_code] end Hash[pairs] end |