Class: JenkinsJob::Cli
- Inherits:
-
Thor
- Object
- Thor
- JenkinsJob::Cli
- Includes:
- Thor::Actions
- Defined in:
- lib/jenkins_job/cli.rb
Instance Method Summary collapse
- #clean(*project) ⇒ Object
- #clone(*project) ⇒ Object
- #copy_setting(source_project, setting_name, *dest_project) ⇒ Object
- #disable(*project) ⇒ Object
- #enable(*project) ⇒ Object
Instance Method Details
#clean(*project) ⇒ Object
41 42 43 44 45 |
# File 'lib/jenkins_job/cli.rb', line 41 def clean *project project.each do |p| Project.new(p).clean end end |
#clone(*project) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jenkins_job/cli.rb', line 11 def clone *project force = [:force] || false project.each do |p| # calculate the new dir new_dir = p.gsub([:original_branch], [:new_branch]) if File.exists?(new_dir) if !force && !yes?("#{new_dir} already exists, delete it? [y/n]") say "#{p} -> #{new_dir} - skipped by user choice", :yellow next else FileUtils.rm_rf(new_dir) end end FileUtils.mkdir_p new_dir config_lines = File.open(File.join(p, 'config.xml'), 'r').readlines File.open(File.join(new_dir, 'config.xml'), 'w') do |file| config_lines.each do |line| file.write(line.gsub([:original_branch], [:new_branch])) end end say "#{p} -> #{new_dir} - done", :green end end |
#copy_setting(source_project, setting_name, *dest_project) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/jenkins_job/cli.rb', line 65 def copy_setting source_project, setting_name, *dest_project source = Project.new(source_project) setting = source.setting(setting_name) if setting.nil? say("#{source_project} doesn't contain the specified setting", :red) Kernel::exit(1) end dest_project.each do |p| dest = Project.new(p) dest.update_setting(setting_name, setting) say("#{setting_name} copied to #{p}", :green) end end |