Class: Jenkins::Capistrano::Configurator
- Inherits:
-
Object
- Object
- Jenkins::Capistrano::Configurator
- Defined in:
- lib/jenkins-capistrano/configurator.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#job_config_dir ⇒ Object
readonly
Returns the value of attribute job_config_dir.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#node_config_dir ⇒ Object
readonly
Returns the value of attribute node_config_dir.
-
#template_vars ⇒ Object
readonly
Returns the value of attribute template_vars.
-
#view_config_dir ⇒ Object
readonly
Returns the value of attribute view_config_dir.
Instance Method Summary collapse
- #configure_jobs(config_files, disabled_jobs) ⇒ Object
- #configure_nodes(config_files) ⇒ Object
- #configure_views(config_files) ⇒ Object
-
#initialize(options = {}) ⇒ Configurator
constructor
A new instance of Configurator.
Constructor Details
#initialize(options = {}) ⇒ Configurator
Returns a new instance of Configurator.
11 12 13 14 15 16 |
# File 'lib/jenkins-capistrano/configurator.rb', line 11 def initialize( = {}) opts = {:log_location => '/dev/null'}.merge() @logger = opts.delete(:logger) @template_vars = opts.delete(:template_vars) @client = JenkinsApi::Client.new(opts) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/jenkins-capistrano/configurator.rb', line 9 def client @client end |
#job_config_dir ⇒ Object (readonly)
Returns the value of attribute job_config_dir.
9 10 11 |
# File 'lib/jenkins-capistrano/configurator.rb', line 9 def job_config_dir @job_config_dir end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
9 10 11 |
# File 'lib/jenkins-capistrano/configurator.rb', line 9 def logger @logger end |
#node_config_dir ⇒ Object (readonly)
Returns the value of attribute node_config_dir.
9 10 11 |
# File 'lib/jenkins-capistrano/configurator.rb', line 9 def node_config_dir @node_config_dir end |
#template_vars ⇒ Object (readonly)
Returns the value of attribute template_vars.
9 10 11 |
# File 'lib/jenkins-capistrano/configurator.rb', line 9 def template_vars @template_vars end |
#view_config_dir ⇒ Object (readonly)
Returns the value of attribute view_config_dir.
9 10 11 |
# File 'lib/jenkins-capistrano/configurator.rb', line 9 def view_config_dir @view_config_dir end |
Instance Method Details
#configure_jobs(config_files, disabled_jobs) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/jenkins-capistrano/configurator.rb', line 18 def configure_jobs(config_files, disabled_jobs) if config_files.empty? logger.important "no node configs found." return end config_files.each do |file| name = name_for(file) client.job.create_or_update(name, config_xml_for(file)) logger.trace "job #{name} created." if disabled_jobs.include? name client.job.disable(name) logger.trace " -> disabled" end end end |
#configure_nodes(config_files) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/jenkins-capistrano/configurator.rb', line 35 def configure_nodes(config_files) if config_files.empty? logger.important "no node configs found." return end config_files.each do |file| name = name_for(file) unless client.node.list.include? name params = { :name => name, :slave_host => 'dummy-by-jenkins-capistrano', :private_key_file => 'dummy' } client.node.create_dumb_slave(params) end client.node.post_config(name, config_xml_for(file)) logger.trace "node #{name} created." end end |
#configure_views(config_files) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/jenkins-capistrano/configurator.rb', line 52 def configure_views(config_files) if config_files.empty? logger.important "no view configs found." return end config_files.each do |file| name = name_for(file) unless client.view.exists? name client.view.create name end client.view.post_config(name, config_xml_for(file)) logger.trace "view #{name} created." end end |