Class: LeeroyJenkins::JobBackupper

Inherits:
Object
  • Object
show all
Defined in:
lib/leeroy_jenkins/job_backupper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_dirObject (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_clientObject (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_backupObject (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

#threadsObject (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

#backupObject



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_configsObject



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