Class: JenkinsPipelineBuilder::JobCollection
- Inherits:
-
Object
- Object
- JenkinsPipelineBuilder::JobCollection
- Defined in:
- lib/jenkins_pipeline_builder/job_collection.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#loaded ⇒ Object
(also: #loaded?)
readonly
Returns the value of attribute loaded.
-
#remote_dependencies ⇒ Object
Returns the value of attribute remote_dependencies.
Instance Method Summary collapse
- #clear_remote_dependencies ⇒ Object
- #defaults ⇒ Object
- #get_item(name) ⇒ Object
-
#initialize ⇒ JobCollection
constructor
A new instance of JobCollection.
- #jobs ⇒ Object
- #load_from_path(path, remote = false) ⇒ Object
- #logger ⇒ Object
- #projects ⇒ Object
- #standalone_jobs ⇒ Object
Constructor Details
#initialize ⇒ JobCollection
Returns a new instance of JobCollection.
7 8 9 10 11 |
# File 'lib/jenkins_pipeline_builder/job_collection.rb', line 7 def initialize @collection = {} @remote_dependencies = RemoteDependencies.new self @loaded = false end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
3 4 5 |
# File 'lib/jenkins_pipeline_builder/job_collection.rb', line 3 def collection @collection end |
#loaded ⇒ Object (readonly) Also known as: loaded?
Returns the value of attribute loaded.
4 5 6 |
# File 'lib/jenkins_pipeline_builder/job_collection.rb', line 4 def loaded @loaded end |
#remote_dependencies ⇒ Object
Returns the value of attribute remote_dependencies.
3 4 5 |
# File 'lib/jenkins_pipeline_builder/job_collection.rb', line 3 def remote_dependencies @remote_dependencies end |
Instance Method Details
#clear_remote_dependencies ⇒ Object
13 14 15 |
# File 'lib/jenkins_pipeline_builder/job_collection.rb', line 13 def clear_remote_dependencies @remote_dependencies = RemoteDependencies.new self end |
#defaults ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/jenkins_pipeline_builder/job_collection.rb', line 33 def defaults collection.each_value do |item| return item if item[:type] == 'defaults' || item[:type] == :defaults end # This is here for historical purposes get_item('global') end |
#get_item(name) ⇒ Object
41 42 43 |
# File 'lib/jenkins_pipeline_builder/job_collection.rb', line 41 def get_item(name) collection[name.to_s] end |
#jobs ⇒ Object
29 30 31 |
# File 'lib/jenkins_pipeline_builder/job_collection.rb', line 29 def jobs collect_type :job end |
#load_from_path(path, remote = false) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/jenkins_pipeline_builder/job_collection.rb', line 45 def load_from_path(path, remote = false) load_extensions(path) path = File.(path, Dir.getwd) if File.directory?(path) logger.info "Generating from folder #{path}" Dir[File.join(path, '/*.{yaml,yml}')].each do |file| load_file(file, remote) end Dir[File.join(path, '/*.json')].each do |file| load_file(file, remote) end else load_file(path, remote) end @loaded = true end |
#logger ⇒ Object
17 18 19 |
# File 'lib/jenkins_pipeline_builder/job_collection.rb', line 17 def logger JenkinsPipelineBuilder.logger end |
#projects ⇒ Object
25 26 27 |
# File 'lib/jenkins_pipeline_builder/job_collection.rb', line 25 def projects collect_type :project end |
#standalone_jobs ⇒ Object
21 22 23 |
# File 'lib/jenkins_pipeline_builder/job_collection.rb', line 21 def standalone_jobs jobs.map { |job| { result: job } } end |