Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

command line option fixes

  • Loading branch information...
commit 53f94a61aa538f658d46255aba892f61ec9c01e1 1 parent 1272ec6
Jenkins CI authored
99 chef-jenkins.gemspec
View
@@ -17,103 +17,8 @@ Gem::Specification.new do |s|
"LICENSE",
"README.rdoc"
]
- s.files = [
- ".document",
- ".rspec",
- "Gemfile",
- "Gemfile.lock",
- "LICENSE",
- "README.rdoc",
- "Rakefile",
- "VERSION",
- "bin/chef-jenkins",
- "lib/chef-jenkins.rb",
- "lib/chef/application/jenkins.rb",
- "lib/chef/jenkins.rb",
- "lib/chef/jenkins/config.rb",
- "spec/assets/config.rb",
- "spec/assets/cookbooks/apache2/README.rdoc",
- "spec/assets/cookbooks/apache2/attributes/default.rb",
- "spec/assets/cookbooks/apache2/definitions/apache_conf.rb",
- "spec/assets/cookbooks/apache2/definitions/apache_module.rb",
- "spec/assets/cookbooks/apache2/definitions/apache_site.rb",
- "spec/assets/cookbooks/apache2/definitions/web_app.rb",
- "spec/assets/cookbooks/apache2/files/default/apache2_module_conf_generate.pl",
- "spec/assets/cookbooks/apache2/metadata.rb",
- "spec/assets/cookbooks/apache2/recipes/default.rb",
- "spec/assets/cookbooks/apache2/recipes/god_monitor.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_alias.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_auth_basic.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_auth_digest.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_auth_openid.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_authn_file.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_authnz_ldap.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_authz_default.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_authz_groupfile.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_authz_host.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_authz_user.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_autoindex.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_cgi.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_dav.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_dav_svn.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_deflate.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_dir.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_env.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_expires.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_fcgid.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_headers.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_ldap.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_log_config.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_mime.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_negotiation.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_php5.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_proxy.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_proxy_ajp.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_proxy_balancer.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_proxy_connect.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_proxy_http.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_python.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_rewrite.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_setenvif.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_ssl.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_status.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_wsgi.rb",
- "spec/assets/cookbooks/apache2/recipes/mod_xsendfile.rb",
- "spec/assets/cookbooks/apache2/templates/default/a2dismod.erb",
- "spec/assets/cookbooks/apache2/templates/default/a2dissite.erb",
- "spec/assets/cookbooks/apache2/templates/default/a2enmod.erb",
- "spec/assets/cookbooks/apache2/templates/default/a2ensite.erb",
- "spec/assets/cookbooks/apache2/templates/default/apache2.conf.erb",
- "spec/assets/cookbooks/apache2/templates/default/apache2.god.erb",
- "spec/assets/cookbooks/apache2/templates/default/charset.erb",
- "spec/assets/cookbooks/apache2/templates/default/default-site.erb",
- "spec/assets/cookbooks/apache2/templates/default/mod_auth_openid.rb.erb",
- "spec/assets/cookbooks/apache2/templates/default/mods/README",
- "spec/assets/cookbooks/apache2/templates/default/mods/alias.conf.erb",
- "spec/assets/cookbooks/apache2/templates/default/mods/authopenid.load.erb",
- "spec/assets/cookbooks/apache2/templates/default/mods/autoindex.conf.erb",
- "spec/assets/cookbooks/apache2/templates/default/mods/deflate.conf.erb",
- "spec/assets/cookbooks/apache2/templates/default/mods/dir.conf.erb",
- "spec/assets/cookbooks/apache2/templates/default/mods/fcgid.conf.erb",
- "spec/assets/cookbooks/apache2/templates/default/mods/mime.conf.erb",
- "spec/assets/cookbooks/apache2/templates/default/mods/negotiation.conf.erb",
- "spec/assets/cookbooks/apache2/templates/default/mods/proxy.conf.erb",
- "spec/assets/cookbooks/apache2/templates/default/mods/setenvif.conf.erb",
- "spec/assets/cookbooks/apache2/templates/default/mods/ssl.conf.erb",
- "spec/assets/cookbooks/apache2/templates/default/mods/status.conf.erb",
- "spec/assets/cookbooks/apache2/templates/default/port_apache.erb",
- "spec/assets/cookbooks/apache2/templates/default/ports.conf.erb",
- "spec/assets/cookbooks/apache2/templates/default/security.erb",
- "spec/assets/cookbooks/apache2/templates/default/web_app.conf.erb",
- "spec/assets/cookbooks/ntp/README.md",
- "spec/assets/cookbooks/ntp/attributes/default.rb",
- "spec/assets/cookbooks/ntp/metadata.rb",
- "spec/assets/cookbooks/ntp/recipes/default.rb",
- "spec/assets/cookbooks/ntp/templates/default/ntp.conf.erb",
- "spec/assets/metadata.rb",
- "spec/chef-jenkins_spec.rb",
- "spec/spec_helper.rb"
- ]
+
+ s.files = `git ls-files`.split($\)
s.homepage = "http://github.com/adamhjk/chef-jenkins"
s.licenses = ["MIT"]
s.require_paths = ["lib"]
52 lib/chef/application/jenkins.rb
View
@@ -21,9 +21,9 @@
class Chef::Application::Jenkins < Chef::Application
- banner "Usage: jenkins (sync|prop) (options)"
+ banner "Usage: jenkins (sync|prop|save|load) (options)"
- NO_COMMAND_GIVEN = "You need to pass either sync or prop as the first argument\n"
+ NO_COMMAND_GIVEN = "You need to pass sync|prop|save|load as the first argument\n"
option :config_file,
:short => "-c CONFIG",
@@ -54,12 +54,12 @@ class Chef::Application::Jenkins < Chef::Application
:description => "API Client Username"
option :test,
- :short => "-t TESTS",
+ :short => "-T TESTS",
:long => "--test TESTS",
:description => "Add test(s) before uploading to chef server; -t ruby,foodcritic"
option :cookbook_freeze,
- :short => "-f",
+ :short => "-F",
:long => "--freeze",
:description => "Freeze cookbook(s) while uploading"
@@ -90,12 +90,56 @@ def run_application
jenkins.sync
elsif ARGV[0] == "prop"
jenkins.prop(config[:env_from], config[:env_to])
+ elsif ARGV[0] == "save"
+ jenkins.save
+ elsif ARGV[0] == "load"
+ jenkins.load
else
Chef::Application.fatal!("You must provide sync or prop as the first argument")
end
exit 0
end
+ def configure_chef
+ begin
+ self.parse_options
+ rescue OptionParser::InvalidOption => e
+ puts "#{e}\n"
+ puts self.opt_parser
+ exit 0
+ rescue OptionParser::MissingArgument => e
+ puts "#{e}\n"
+ puts self.opt_parser
+ exit 0
+ end
+
+ if config[:help]
+ puts self.opt_parser
+ exit 0
+ end
+
+ begin
+ case config[:config_file]
+ when /^(http|https):\/\//
+ Chef::REST.new("", nil, nil).fetch(config[:config_file]) { |f| apply_config(f.path) }
+ else
+ ::File::open(config[:config_file]) { |f| apply_config(f.path) }
+ end
+ rescue Errno::ENOENT => error
+ Chef::Log.warn("*****************************************")
+ Chef::Log.warn("Did not find config file: #{config[:config_file]}, using command line options.")
+ Chef::Log.warn("*****************************************")
+
+ Chef::Config.merge!(config)
+ rescue SocketError => error
+ Chef::Application.fatal!("Error getting config file #{Chef::Config[:config_file]}", 2)
+ rescue Chef::Exceptions::ConfigurationError => error
+ Chef::Application.fatal!("Error processing config file #{Chef::Config[:config_file]} with error #{error.message}", 2)
+ rescue Exception => error
+ Chef::Application.fatal!("Unknown error processing config file #{Chef::Config[:config_file]} with error #{error.message}", 2)
+ end
+ end
+
def setup_application
end
21 lib/chef/jenkins.rb
View
@@ -35,7 +35,7 @@
class Chef
class Jenkins
- VERSION = "0.1.0"
+ VERSION = "0.1.2"
attr_accessor :git
@@ -251,7 +251,13 @@ def upload_cookbooks(cookbooks=[])
cu = Chef::Knife::CookbookUpload.new
cu.name_args = cookbooks
cu.config[:environment] = Chef::Config[:jenkins][:env_to]
- cu.config[:freeze] = Chef::Config[:cookbook_freeze] ? true : false
+ if Chef::Config[:cookbook_freeze]
+ cu.config[:freeze] = true
+ elsif !! Chef::Config[:jenkins][:cookbook_freeze] == Chef::Config[:jenkins][:cookbook_freeze]
+ cu.config[:freeze] = Chef::Config[:jenkins][:cookbook_freeze]
+ else
+ cu.config[:freeze] = false
+ end
cu.run
save_environment_file
end
@@ -368,8 +374,19 @@ def prop(env_from=Chef::Config[:jenkins][:env_from], env_to=Chef::Config[:jenkin
push_to_upstream
end
+ def save(cookbook_path=Chef::Config[:cookbook_path], role_path=Chef::Config[:role_path], repo_dir=Chef::Config[:jenkins][:repo_dir])
+ puts cookbook_path
+ puts role_path
+ puts repo_dir
+ puts Chef::Config[:jenkins][:cookbook_freeze]
+ end
+
+ def load()
+ end
+
# Sync cookbooks, roles, and data_bags to chef_server while pushing changes to git repo
def sync(cookbook_path=Chef::Config[:cookbook_path], role_path=Chef::Config[:role_path], repo_dir=Chef::Config[:jenkins][:repo_dir])
+
add_upstream
git_branch(integration_branch_name)
1  spec/assets/config.rb
View
@@ -18,6 +18,7 @@
:git_email => "jenkins@promethost.com",
:env_to => "ops",
:branch => "master",
+ :cookbook_freeze => false,
:foodcritic => {
:fail_tags => ["correctness"],
:tags => [],
8 spec/chef-jenkins_spec.rb
View
@@ -96,8 +96,8 @@
it "prints a list of cookbooks changed since last commit" do
system("echo '#test' >> #{AH::INFLIGHT}/cookbooks/ntp/metadata.rb")
system("cd #{AH::INFLIGHT}; git commit -am 'changed cookbook ntp';")
- cblist = @cj.find_changed_cookbooks('HEAD^', 'HEAD', ["#{AH::INFLIGHT}/cookbooks"])
- cblist.include?("ntp").should == true
+ changed_list, deleted_list = @cj.find_changed_cookbooks('HEAD^', 'HEAD', ["#{AH::INFLIGHT}/cookbooks"])
+ changed_list.include?("ntp").should == true
end
end
@@ -106,7 +106,7 @@
system("echo '#test' >> #{AH::INFLIGHT}/roles/apache2.rb")
system("echo '#test' >> #{AH::INFLIGHT}/roles/vagrant.rb")
system("cd #{AH::INFLIGHT}; git commit -am 'changed 2 roles';")
- role_list = @cj.find_changed_roles('HEAD^', 'HEAD', ["#{AH::INFLIGHT}/roles"])
+ role_list, deleted_list = @cj.find_changed_roles('HEAD^', 'HEAD', ["#{AH::INFLIGHT}/roles"])
role_list = role_list.map {|i| File.basename(i)}
role_list.include?("apache2.rb").should == true
role_list.include?("vagrant.rb").should == true
@@ -118,7 +118,7 @@
system("echo '#test' >> #{AH::INFLIGHT}/data_bags/users/foobar.json")
system("echo '#test' >> #{AH::INFLIGHT}/data_bags/groups/ops.json")
system("cd #{AH::INFLIGHT}; git commit -am 'changed 2 databags';")
- data_bag_list = @cj.find_changed_data_bags('HEAD^', 'HEAD', ["#{AH::INFLIGHT}/data_bags"])
+ data_bag_list, deleted_list = @cj.find_changed_data_bags('HEAD^', 'HEAD', ["#{AH::INFLIGHT}/data_bags"])
data_bag_list = data_bag_list.map {|i| File.basename(i)}
data_bag_list.include?("foobar.json").should == true
data_bag_list.include?("ops.json").should == true
Please sign in to comment.
Something went wrong with that request. Please try again.