Class: LeeroyJenkins::JobBackupper
- Inherits:
-
Object
- Object
- LeeroyJenkins::JobBackupper
- Defined in:
- lib/leeroy_jenkins/job_backupper.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.
-
#job_names_to_backup ⇒ Object
readonly
Returns the value of attribute job_names_to_backup.
-
#threads ⇒ Object
readonly
Returns the value of attribute threads.
Instance Method Summary collapse
- #backup ⇒ Object
- #get_job_configs ⇒ Object
-
#initialize(job_names_to_backup, jenkins_client, backup_dir, threads) ⇒ JobBackupper
constructor
A new instance of JobBackupper.
Constructor Details
#initialize(job_names_to_backup, jenkins_client, backup_dir, threads) ⇒ JobBackupper
Returns a new instance of JobBackupper.
5 6 7 8 9 10 |
# File 'lib/leeroy_jenkins/job_backupper.rb', line 5 def initialize(job_names_to_backup, jenkins_client, backup_dir, threads) @job_names_to_backup = job_names_to_backup @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_backupper.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_backupper.rb', line 3 def jenkins_client @jenkins_client end |
#job_names_to_backup ⇒ Object (readonly)
Returns the value of attribute job_names_to_backup.
3 4 5 |
# File 'lib/leeroy_jenkins/job_backupper.rb', line 3 def job_names_to_backup @job_names_to_backup end |
#threads ⇒ Object (readonly)
Returns the value of attribute threads.
3 4 5 |
# File 'lib/leeroy_jenkins/job_backupper.rb', line 3 def threads @threads end |
Instance Method Details
#backup ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/leeroy_jenkins/job_backupper.rb', line 20 def backup unless Dir.exists? backup_dir FileUtils.mkdir_p backup_dir end map_job_configs do |job_name, job_config| File.write "#{backup_dir}/#{job_name}.xml", job_config end end |
#get_job_configs ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/leeroy_jenkins/job_backupper.rb', line 12 def get_job_configs pairs = map_job_configs do |job_name, job_config| [job_name, job_config] end Hash[pairs] end |