Class: JenkinsPipelineBuilder::RemoteDependencies

Inherits:
Object
  • Object
show all
Defined in:
lib/jenkins_pipeline_builder/remote_dependencies.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_collection) ⇒ RemoteDependencies

Returns a new instance of RemoteDependencies.



5
6
7
8
# File 'lib/jenkins_pipeline_builder/remote_dependencies.rb', line 5

def initialize(job_collection)
  @entries = {}
  @job_collection = job_collection
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



3
4
5
# File 'lib/jenkins_pipeline_builder/remote_dependencies.rb', line 3

def entries
  @entries
end

#job_collectionObject (readonly)

Returns the value of attribute job_collection.



3
4
5
# File 'lib/jenkins_pipeline_builder/remote_dependencies.rb', line 3

def job_collection
  @job_collection
end

Instance Method Details

#cleanupObject



14
15
16
17
18
19
# File 'lib/jenkins_pipeline_builder/remote_dependencies.rb', line 14

def cleanup
  entries.each_value do |file|
    FileUtils.rm_r file
    FileUtils.rm_r "#{file}.tar"
  end
end

#load(dependencies) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/jenkins_pipeline_builder/remote_dependencies.rb', line 21

def load(dependencies)
  dependencies.each do |source|
    source = source[:source]
    url = source[:url]

    file = "remote-#{entries.length}"
    if entries[url]
      file = entries[url]
    else
      opts = {}
      opts = { ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE } if source[:verify_ssl] == false
      download_yaml(url, file, opts)
    end

    path = File.expand_path(file, Dir.getwd)
    return load_default_path path unless source[:templates]

    load_templates(path, source[:templates])
  end
end

#loggerObject



10
11
12
# File 'lib/jenkins_pipeline_builder/remote_dependencies.rb', line 10

def logger
  JenkinsPipelineBuilder.logger
end