hudson 0.3.0.beta.17 → 0.3.0.beta.18

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hudson (0.3.0.beta.17)
4
+ hudson (0.3.0.beta.18)
5
5
  builder (~> 2.1.2)
6
6
  hpricot
7
7
  httparty (~> 0.6.1)
@@ -6,14 +6,13 @@ Feature: Adding slave nodes
6
6
  Background:
7
7
  Given I have a Hudson server running
8
8
  And the Hudson server has no slaves
9
-
10
- Scenario: List available slaves (hudson nodes)
11
9
  When I run local executable "hudson" with arguments "nodes --host localhost --port 3010"
12
10
  Then I should see exactly
13
11
  """
14
12
  master
15
13
  """
16
14
 
15
+ Scenario: Add slave via API (hudson nodes)
17
16
  When I create a new node with the following options on "http://localhost:3010":
18
17
  | name | Slave 1 |
19
18
  | label | app1 app2 app3 |
@@ -24,4 +23,23 @@ Feature: Adding slave nodes
24
23
  """
25
24
  master
26
25
  Slave 1
26
+ """
27
+
28
+ Scenario: Add slave via CLI with name defaulted to URL (hudson add_node)
29
+ When I run local executable "hudson" with arguments "add_node foo1.bar.com --slave-user deploy --label 'app1 app2' --host localhost --port 3010"
30
+ Then I should see exactly
31
+ """
32
+ Added slave node foo1.bar.com
33
+ """
34
+ When I run local executable "hudson" with arguments "add_node foo1.bar.com --slave-user deploy --label 'app1 app2' --host localhost --port 3010"
35
+ Then I should see exactly
36
+ """
37
+ Slave called 'foo1.bar.com' already exists
38
+ ERROR: Failed to add slave node foo1.bar.com
39
+ """
40
+ When I run local executable "hudson" with arguments "nodes"
41
+ Then I should see exactly
42
+ """
43
+ master
44
+ foo1.bar.com
27
45
  """
data/hudson.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{hudson}
5
- s.version = "0.3.0.beta.17"
5
+ s.version = "0.3.0.beta.18"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Charles Lowell", "Dr Nic Williams"]
9
- s.date = %q{2010-11-03}
9
+ s.date = %q{2010-11-06}
10
10
  s.default_executable = %q{hudson}
11
11
  s.description = %q{A suite of utilities for bringing continous integration to your projects (not the other way around) with hudson CI}
12
12
  s.email = ["cowboyd@thefrontside.net", "drnicwilliams@gmail.com"]
13
13
  s.executables = ["hudson"]
14
- s.files = ["bin", "bin/hudson", "features", "features/development.feature", "features/launch_server.feature", "features/listing_jobs.feature", "features/manage_jobs.feature", "features/manage_slave_nodes.feature", "features/step_definitions", "features/step_definitions/common_steps.rb", "features/step_definitions/fixture_project_steps.rb", "features/step_definitions/hudson_steps.rb", "features/step_definitions/scm_steps.rb", "features/support", "features/support/common.rb", "features/support/env.rb", "features/support/hooks.rb", "features/support/matchers.rb", "fixtures", "fixtures/projects", "fixtures/projects/non-bundler", "fixtures/projects/non-bundler/Rakefile", "fixtures/projects/rails-3", "fixtures/projects/rails-3/app", "fixtures/projects/rails-3/app/controllers", "fixtures/projects/rails-3/app/controllers/application_controller.rb", "fixtures/projects/rails-3/app/helpers", "fixtures/projects/rails-3/app/helpers/application_helper.rb", "fixtures/projects/rails-3/app/mailers", "fixtures/projects/rails-3/app/models", "fixtures/projects/rails-3/app/views", "fixtures/projects/rails-3/app/views/layouts", "fixtures/projects/rails-3/app/views/layouts/application.html.erb", "fixtures/projects/rails-3/config", "fixtures/projects/rails-3/config/application.rb", "fixtures/projects/rails-3/config/boot.rb", "fixtures/projects/rails-3/config/database.yml", "fixtures/projects/rails-3/config/environment.rb", "fixtures/projects/rails-3/config/environments", "fixtures/projects/rails-3/config/environments/development.rb", "fixtures/projects/rails-3/config/environments/production.rb", "fixtures/projects/rails-3/config/environments/test.rb", "fixtures/projects/rails-3/config/initializers", "fixtures/projects/rails-3/config/initializers/backtrace_silencers.rb", "fixtures/projects/rails-3/config/initializers/inflections.rb", "fixtures/projects/rails-3/config/initializers/mime_types.rb", "fixtures/projects/rails-3/config/initializers/secret_token.rb", "fixtures/projects/rails-3/config/initializers/session_store.rb", "fixtures/projects/rails-3/config/locales", "fixtures/projects/rails-3/config/locales/en.yml", "fixtures/projects/rails-3/config/routes.rb", "fixtures/projects/rails-3/config.ru", "fixtures/projects/rails-3/db", "fixtures/projects/rails-3/db/seeds.rb", "fixtures/projects/rails-3/doc", "fixtures/projects/rails-3/doc/README_FOR_APP", "fixtures/projects/rails-3/Gemfile", "fixtures/projects/rails-3/Gemfile.lock", "fixtures/projects/rails-3/lib", "fixtures/projects/rails-3/lib/tasks", "fixtures/projects/rails-3/log", "fixtures/projects/rails-3/log/development.log", "fixtures/projects/rails-3/log/production.log", "fixtures/projects/rails-3/log/server.log", "fixtures/projects/rails-3/log/test.log", "fixtures/projects/rails-3/public", "fixtures/projects/rails-3/public/404.html", "fixtures/projects/rails-3/public/422.html", "fixtures/projects/rails-3/public/500.html", "fixtures/projects/rails-3/public/favicon.ico", "fixtures/projects/rails-3/public/images", "fixtures/projects/rails-3/public/images/rails.png", "fixtures/projects/rails-3/public/index.html", "fixtures/projects/rails-3/public/javascripts", "fixtures/projects/rails-3/public/javascripts/application.js", "fixtures/projects/rails-3/public/javascripts/controls.js", "fixtures/projects/rails-3/public/javascripts/dragdrop.js", "fixtures/projects/rails-3/public/javascripts/effects.js", "fixtures/projects/rails-3/public/javascripts/prototype.js", "fixtures/projects/rails-3/public/javascripts/rails.js", "fixtures/projects/rails-3/public/robots.txt", "fixtures/projects/rails-3/public/stylesheets", "fixtures/projects/rails-3/Rakefile", "fixtures/projects/rails-3/README", "fixtures/projects/rails-3/script", "fixtures/projects/rails-3/script/rails", "fixtures/projects/rails-3/test", "fixtures/projects/rails-3/test/fixtures", "fixtures/projects/rails-3/test/functional", "fixtures/projects/rails-3/test/integration", "fixtures/projects/rails-3/test/performance", "fixtures/projects/rails-3/test/performance/browsing_test.rb", "fixtures/projects/rails-3/test/test_helper.rb", "fixtures/projects/rails-3/test/unit", "fixtures/projects/rails-3/vendor", "fixtures/projects/rails-3/vendor/plugins", "fixtures/projects/ruby", "fixtures/projects/ruby/Gemfile", "fixtures/projects/ruby/Gemfile.lock", "fixtures/projects/ruby/Rakefile", "Gemfile", "Gemfile.lock", "hudson.gemspec", "lib", "lib/hudson", "lib/hudson/api.rb", "lib/hudson/cli", "lib/hudson/cli/formatting.rb", "lib/hudson/cli.rb", "lib/hudson/config.rb", "lib/hudson/core_ext", "lib/hudson/core_ext/object", "lib/hudson/core_ext/object/blank.rb", "lib/hudson/hudson-cli.jar", "lib/hudson/hudson.war", "lib/hudson/hudson_version.rb", "lib/hudson/job_config_builder.rb", "lib/hudson/plugins", "lib/hudson/plugins/envfile.hpi", "lib/hudson/plugins/git.hpi", "lib/hudson/plugins/github.hpi", "lib/hudson/plugins/greenballs.hpi", "lib/hudson/plugins/rake.hpi", "lib/hudson/plugins/ruby.hpi", "lib/hudson/project_scm.rb", "lib/hudson/remote.rb", "lib/hudson/version.rb", "lib/hudson.rb", "Rakefile", "README.md", "spec", "spec/fixtures", "spec/fixtures/ec2_global.config.xml", "spec/fixtures/rails.multi.config.xml", "spec/fixtures/rails.single.config.triggers.xml", "spec/fixtures/rails.single.config.xml", "spec/fixtures/ruby.single.config.xml", "spec/fixtures/rubygem.config.xml", "spec/fixtures/therubyracer.config.xml", "spec/job_config_builder_spec.rb", "spec/spec_helper.rb", "tasks", "tasks/upgrade.rake"]
14
+ s.files = ["bin", "bin/hudson", "features", "features/development.feature", "features/launch_server.feature", "features/listing_jobs.feature", "features/manage_jobs.feature", "features/manage_slave_nodes.feature", "features/step_definitions", "features/step_definitions/common_steps.rb", "features/step_definitions/fixture_project_steps.rb", "features/step_definitions/hudson_steps.rb", "features/step_definitions/scm_steps.rb", "features/support", "features/support/common.rb", "features/support/env.rb", "features/support/hooks.rb", "features/support/matchers.rb", "fixtures", "fixtures/projects", "fixtures/projects/non-bundler", "fixtures/projects/non-bundler/Rakefile", "fixtures/projects/rails-3", "fixtures/projects/rails-3/app", "fixtures/projects/rails-3/app/controllers", "fixtures/projects/rails-3/app/controllers/application_controller.rb", "fixtures/projects/rails-3/app/helpers", "fixtures/projects/rails-3/app/helpers/application_helper.rb", "fixtures/projects/rails-3/app/mailers", "fixtures/projects/rails-3/app/models", "fixtures/projects/rails-3/app/views", "fixtures/projects/rails-3/app/views/layouts", "fixtures/projects/rails-3/app/views/layouts/application.html.erb", "fixtures/projects/rails-3/config", "fixtures/projects/rails-3/config/application.rb", "fixtures/projects/rails-3/config/boot.rb", "fixtures/projects/rails-3/config/database.yml", "fixtures/projects/rails-3/config/environment.rb", "fixtures/projects/rails-3/config/environments", "fixtures/projects/rails-3/config/environments/development.rb", "fixtures/projects/rails-3/config/environments/production.rb", "fixtures/projects/rails-3/config/environments/test.rb", "fixtures/projects/rails-3/config/initializers", "fixtures/projects/rails-3/config/initializers/backtrace_silencers.rb", "fixtures/projects/rails-3/config/initializers/inflections.rb", "fixtures/projects/rails-3/config/initializers/mime_types.rb", "fixtures/projects/rails-3/config/initializers/secret_token.rb", "fixtures/projects/rails-3/config/initializers/session_store.rb", "fixtures/projects/rails-3/config/locales", "fixtures/projects/rails-3/config/locales/en.yml", "fixtures/projects/rails-3/config/routes.rb", "fixtures/projects/rails-3/config.ru", "fixtures/projects/rails-3/db", "fixtures/projects/rails-3/db/seeds.rb", "fixtures/projects/rails-3/doc", "fixtures/projects/rails-3/doc/README_FOR_APP", "fixtures/projects/rails-3/Gemfile", "fixtures/projects/rails-3/Gemfile.lock", "fixtures/projects/rails-3/lib", "fixtures/projects/rails-3/lib/tasks", "fixtures/projects/rails-3/log", "fixtures/projects/rails-3/log/development.log", "fixtures/projects/rails-3/log/production.log", "fixtures/projects/rails-3/log/server.log", "fixtures/projects/rails-3/log/test.log", "fixtures/projects/rails-3/public", "fixtures/projects/rails-3/public/404.html", "fixtures/projects/rails-3/public/422.html", "fixtures/projects/rails-3/public/500.html", "fixtures/projects/rails-3/public/favicon.ico", "fixtures/projects/rails-3/public/images", "fixtures/projects/rails-3/public/images/rails.png", "fixtures/projects/rails-3/public/index.html", "fixtures/projects/rails-3/public/javascripts", "fixtures/projects/rails-3/public/javascripts/application.js", "fixtures/projects/rails-3/public/javascripts/controls.js", "fixtures/projects/rails-3/public/javascripts/dragdrop.js", "fixtures/projects/rails-3/public/javascripts/effects.js", "fixtures/projects/rails-3/public/javascripts/prototype.js", "fixtures/projects/rails-3/public/javascripts/rails.js", "fixtures/projects/rails-3/public/robots.txt", "fixtures/projects/rails-3/public/stylesheets", "fixtures/projects/rails-3/Rakefile", "fixtures/projects/rails-3/README", "fixtures/projects/rails-3/script", "fixtures/projects/rails-3/script/rails", "fixtures/projects/rails-3/test", "fixtures/projects/rails-3/test/fixtures", "fixtures/projects/rails-3/test/functional", "fixtures/projects/rails-3/test/integration", "fixtures/projects/rails-3/test/performance", "fixtures/projects/rails-3/test/performance/browsing_test.rb", "fixtures/projects/rails-3/test/test_helper.rb", "fixtures/projects/rails-3/test/unit", "fixtures/projects/rails-3/vendor", "fixtures/projects/rails-3/vendor/plugins", "fixtures/projects/ruby", "fixtures/projects/ruby/Gemfile", "fixtures/projects/ruby/Gemfile.lock", "fixtures/projects/ruby/Rakefile", "Gemfile", "Gemfile.lock", "hudson.gemspec", "lib", "lib/hudson", "lib/hudson/api.rb", "lib/hudson/cli", "lib/hudson/cli/formatting.rb", "lib/hudson/cli.rb", "lib/hudson/config.rb", "lib/hudson/core_ext", "lib/hudson/core_ext/hash.rb", "lib/hudson/core_ext/object", "lib/hudson/core_ext/object/blank.rb", "lib/hudson/hudson-cli.jar", "lib/hudson/hudson.war", "lib/hudson/hudson_version.rb", "lib/hudson/job_config_builder.rb", "lib/hudson/plugins", "lib/hudson/plugins/envfile.hpi", "lib/hudson/plugins/git.hpi", "lib/hudson/plugins/github.hpi", "lib/hudson/plugins/greenballs.hpi", "lib/hudson/plugins/rake.hpi", "lib/hudson/plugins/ruby.hpi", "lib/hudson/project_scm.rb", "lib/hudson/remote.rb", "lib/hudson/version.rb", "lib/hudson.rb", "Rakefile", "README.md", "spec", "spec/fixtures", "spec/fixtures/ec2_global.config.xml", "spec/fixtures/rails.multi.config.xml", "spec/fixtures/rails.single.config.triggers.xml", "spec/fixtures/rails.single.config.xml", "spec/fixtures/ruby.single.config.xml", "spec/fixtures/rubygem.config.xml", "spec/fixtures/therubyracer.config.xml", "spec/hash_key_cleaner_spec.rb", "spec/job_config_builder_spec.rb", "spec/spec_helper.rb", "tasks", "tasks/upgrade.rake"]
15
15
  s.homepage = %q{http://github.com/cowboyd/hudson.rb}
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{hudson}
data/lib/hudson/api.rb CHANGED
@@ -3,6 +3,7 @@ require 'cgi'
3
3
  require 'uri'
4
4
  require 'json'
5
5
 
6
+ require 'hudson/core_ext/hash'
6
7
  require 'hudson/config'
7
8
 
8
9
  module Hudson
@@ -16,6 +17,7 @@ module Hudson
16
17
  JobAlreadyExistsError = Class.new(Exception)
17
18
 
18
19
  def self.setup_base_url(options)
20
+ options = options.with_clean_keys
19
21
  # Thor's HashWithIndifferentAccess is based on string keys which URI::HTTP.build ignores
20
22
  options = options.inject({}) { |mem, (key, val)| mem[key.to_sym] = val; mem }
21
23
  options[:host] ||= ENV['HUDSON_HOST']
@@ -36,6 +38,7 @@ module Hudson
36
38
  #
37
39
  # TODO Exceptions?
38
40
  def self.create_job(name, job_config, options = {})
41
+ options = options.with_clean_keys
39
42
  delete_job(name) if options[:override]
40
43
  begin
41
44
  res = post "/createItem/api/xml?name=#{CGI.escape(name)}", {
@@ -103,19 +106,22 @@ module Hudson
103
106
 
104
107
  # Adds SSH nodes only, for now
105
108
  def self.add_node(options = {})
106
- default_options = Hash.new("")
109
+ options = options.with_clean_keys
110
+ default_options = Hash.new
107
111
  default_options.merge!(
108
112
  :slave_port => 22,
109
- :master_key => "/home/hudson/.ssh/id_rsa", # FIXME - hardcoded master username assumption
110
- :remote_fs => "/data/hudson-slave/",
113
+ :master_key => "/home/deploy/.ssh/id_rsa", # FIXME - hardcoded master username assumption
114
+ :slave_fs => "/data/hudson-slave/",
111
115
  :description => "Automatically created by Hudson.rb",
112
116
  :executors => 2,
113
117
  :exclusive => true
114
118
  )
115
119
 
116
- options = default_options.merge(options)
120
+ slave_host = options[:slave_host]
121
+ name = options[:name] || slave_host
117
122
 
118
- name = options[:name]
123
+ options = default_options.merge(options)
124
+
119
125
  type = "hudson.slaves.DumbSlave$DescriptorImpl"
120
126
 
121
127
  fields = {
@@ -126,7 +132,7 @@ module Hudson
126
132
  "name" => name,
127
133
  "nodeDescription" => options[:description],
128
134
  "numExecutors" => options[:executors],
129
- "remoteFS" => options[:remote_fs],
135
+ "remoteFS" => options[:slave_fs],
130
136
  "labelString" => options[:label],
131
137
  "mode" => options[:exclusive] ? "EXCLUSIVE" : "NORMAL",
132
138
  "type" => type,
@@ -134,24 +140,36 @@ module Hudson
134
140
  "nodeProperties" => { "stapler-class-bag" => "true" },
135
141
  "launcher" => {
136
142
  "stapler-class" => "hudson.plugins.sshslaves.SSHLauncher",
137
- "host" => options[:slave_host],
143
+ "host" => slave_host,
144
+ "port" => options[:slave_port],
138
145
  "username" => options[:slave_user],
139
146
  "privatekey" => options[:master_key],
140
- "port" => options[:slave_port]
141
147
  }
142
148
  }.to_json
143
149
  }
144
150
 
145
151
  url = URI.parse("#{base_uri}/computer/doCreateItem")
152
+
146
153
  req = Net::HTTP::Post.new(url.path)
147
154
  req.set_form_data(fields)
148
155
 
149
156
  http = Net::HTTP.new(url.host, url.port)
150
157
 
151
- case http.request(req)
158
+ response = http.request(req)
159
+ case response
152
160
  when Net::HTTPFound
153
161
  true
154
162
  else
163
+ # error message looks like:
164
+ # <td id="main-panel">
165
+ # <h1>Error</h1><p>Slave called 'localhost' already exists</p>
166
+ require "hpricot"
167
+ error = Hpricot(response.body).search("td#main-panel p").text
168
+ unless error.blank?
169
+ puts error
170
+ else
171
+ puts response.body # so we can find other errors
172
+ end
155
173
  false
156
174
  end
157
175
  end
@@ -162,12 +180,14 @@ module Hudson
162
180
 
163
181
  # Helper for POST that don't barf at Hudson's crappy API responses
164
182
  def self.post_plain(path, options = {})
183
+ options = options.with_clean_keys
165
184
  uri = URI.parse base_uri
166
185
  res = Net::HTTP.start(uri.host, uri.port) { |http| http.post(path, options) }
167
186
  end
168
187
 
169
188
  # Helper for GET that don't barf at Hudson's crappy API responses
170
189
  def self.get_plain(path, options = {})
190
+ options = options.with_clean_keys
171
191
  uri = URI.parse base_uri
172
192
  res = Net::HTTP.start(uri.host, uri.port) { |http| http.get(path, options) }
173
193
  end
data/lib/hudson/cli.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'thor'
2
2
  require 'hudson/core_ext/object/blank'
3
+ require 'hudson/core_ext/hash'
3
4
  require 'hudson/cli/formatting'
4
5
  require 'hudson/remote'
5
6
 
@@ -50,8 +51,8 @@ module Hudson
50
51
  common_options
51
52
  method_option :"no-build", :desc => "create job without initial build", :type => :boolean, :default => false
52
53
  method_option :override, :desc => "override if job exists", :type => :boolean, :default => false
53
- method_option :public_scm, :desc => "use public scm URL", :type => :boolean, :default => false
54
- method_option :assigned_node, :desc => "only use slave nodes with this label"
54
+ method_option :"public-scm", :desc => "use public scm URL", :type => :boolean, :default => false
55
+ method_option :"assigned-node", :desc => "only use slave nodes with this label"
55
56
  method_option :template, :desc => "template of job steps (available: #{JobConfigBuilder::VALID_JOB_TEMPLATES.join ','})", :default => 'ruby'
56
57
  def create(project_path)
57
58
  select_hudson_server(options)
@@ -66,8 +67,8 @@ module Hudson
66
67
  template = options[:template]
67
68
  job_config = Hudson::JobConfigBuilder.new(template) do |c|
68
69
  c.scm = scm.url
69
- c.assigned_node = options[:assigned_node] if options[:assigned_node]
70
- c.public_scm = options[:public_scm]
70
+ c.assigned_node = options[:"assigned-node"] if options[:"assigned-node"]
71
+ c.public_scm = options[:"public-scm"]
71
72
  end
72
73
  name = File.basename(FileUtils.pwd)
73
74
  if Hudson::Api.create_job(name, job_config, options)
@@ -152,6 +153,23 @@ module Hudson
152
153
  shell.say node["displayName"], color
153
154
  end
154
155
  end
156
+
157
+ desc "add_node SLAVE_HOST", "add a URI (user@host:port) server as a slave node"
158
+ method_option :label, :desc => 'Labels for a job --assigned_node to match against to select a slave. Space separated list.'
159
+ method_option :"slave-user", :desc => 'SSH user for Hudson to connect to slave node', :default => "deploy"
160
+ method_option :"slave-port", :desc => 'SSH port for Hudson to connect to slave node', :default => 22
161
+ method_option :"master-key", :desc => 'Location of master public key or identity file'
162
+ method_option :"slave-fs", :desc => 'Location of file system on slave for Hudson to use'
163
+ method_option :name, :desc => 'Name of slave node (default SLAVE_HOST)'
164
+ common_options
165
+ def add_node(slave_host)
166
+ select_hudson_server(options)
167
+ if Hudson::Api.add_node({:slave_host => slave_host}.merge(options))
168
+ shell.say "Added slave node #{slave_host}", :green
169
+ else
170
+ error "Failed to add slave node #{slave_host}"
171
+ end
172
+ end
155
173
 
156
174
  desc "help [command]", "show help for hudson or for a specific command"
157
175
  def help(*args)
@@ -0,0 +1,9 @@
1
+ class Hash
2
+ def with_clean_keys
3
+ self.inject({}) do |mem, (key, value)|
4
+ clean_key = key.to_s.gsub(/-/,"_").to_sym
5
+ mem[clean_key] = value
6
+ mem
7
+ end
8
+ end
9
+ end
@@ -138,8 +138,9 @@ module Hudson
138
138
  end
139
139
  end
140
140
 
141
- # TODO modularise this
142
- # TODO how to customize? e.g. EngineYard template?
141
+ # The important sequence of steps that are run to process a job build.
142
+ # Can be defaulted by the +job_type+ using +default_steps(job_type)+,
143
+ # or customized via +steps+ array.
143
144
  def build_steps(b)
144
145
  b.builders do
145
146
  self.steps ||= default_steps(job_type)
@@ -163,7 +164,14 @@ module Hudson
163
164
  FileUtils.cp example, "config/database.yml"
164
165
  end
165
166
  RUBY
166
- [:build_shell_step, "bundle exec rake db:schema:load"],
167
+ [:build_shell_step, "bundle exec rake db:create:all"],
168
+ [:build_shell_step, <<-RUBY.gsub(/^ /, '')],
169
+ if [ -f db/schema.rb ]; then
170
+ bundle exec rake db:migrate
171
+ else
172
+ bundle exec rake db:schema:load
173
+ fi
174
+ RUBY
167
175
  [:build_shell_step, "bundle exec rake"]
168
176
  ]
169
177
  else
@@ -1,3 +1,3 @@
1
1
  module Hudson
2
- VERSION = "0.3.0.beta.17"
2
+ VERSION = "0.3.0.beta.18"
3
3
  end
@@ -60,7 +60,15 @@ end
60
60
  </command>
61
61
  </hudson.plugins.ruby.Ruby>
62
62
  <hudson.tasks.Shell>
63
- <command>bundle exec rake db:schema:load</command>
63
+ <command>bundle exec rake db:create:all</command>
64
+ </hudson.tasks.Shell>
65
+ <hudson.tasks.Shell>
66
+ <command>if [ -f db/schema.rb ]; then
67
+ bundle exec rake db:migrate
68
+ else
69
+ bundle exec rake db:schema:load
70
+ fi
71
+ </command>
64
72
  </hudson.tasks.Shell>
65
73
  <hudson.tasks.Shell>
66
74
  <command>bundle exec rake</command>
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ require "hudson/core_ext/hash"
4
+
5
+ describe Hash do
6
+ subject do
7
+ {
8
+ :simple => "simple",
9
+ :under_score => "under_score",
10
+ :"hyp-hen" => "hyphen",
11
+ "str_under_score" => "str_under_score",
12
+ "str-hyp-hen" => "str-hyp-hen"
13
+ }
14
+ end
15
+
16
+ it do
17
+ subject.with_clean_keys.should == {
18
+ :simple => "simple",
19
+ :under_score => "under_score",
20
+ :hyp_hen => "hyphen",
21
+ :str_under_score => "str_under_score",
22
+ :str_hyp_hen => "str-hyp-hen"
23
+ }
24
+ end
25
+ end
@@ -5,16 +5,17 @@ describe Hudson::JobConfigBuilder do
5
5
 
6
6
  describe "explicit steps to match a ruby job" do
7
7
  before do
8
- @config = Hudson::JobConfigBuilder.new do |c|
8
+ @config = Hudson::JobConfigBuilder.new(:rails) do |c|
9
9
  c.scm = "git://codebasehq.com/mocra/misc/mocra-web.git"
10
10
  c.steps = [
11
- [:build_shell_step, "bundle install"],
12
- [:build_shell_step, "bundle exec rake"]
11
+ [:build_shell_step, "step 1"],
12
+ [:build_shell_step, "step 2"]
13
13
  ]
14
14
  end
15
15
  end
16
16
  it "builds config.xml" do
17
- config_xml("ruby", "single").should == @config.to_xml
17
+ steps = Hpricot.XML(@config.to_xml).search("command")
18
+ steps.map(&:inner_text).should == ["step 1", "step 2"]
18
19
  end
19
20
  end
20
21
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hudson
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196401
4
+ hash: 62196407
5
5
  prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
9
  - 0
10
10
  - beta
11
- - 17
12
- version: 0.3.0.beta.17
11
+ - 18
12
+ version: 0.3.0.beta.18
13
13
  platform: ruby
14
14
  authors:
15
15
  - Charles Lowell
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-11-03 00:00:00 -07:00
21
+ date: 2010-11-06 00:00:00 -07:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -273,6 +273,7 @@ files:
273
273
  - lib/hudson/cli/formatting.rb
274
274
  - lib/hudson/cli.rb
275
275
  - lib/hudson/config.rb
276
+ - lib/hudson/core_ext/hash.rb
276
277
  - lib/hudson/core_ext/object/blank.rb
277
278
  - lib/hudson/hudson-cli.jar
278
279
  - lib/hudson/hudson.war
@@ -297,6 +298,7 @@ files:
297
298
  - spec/fixtures/ruby.single.config.xml
298
299
  - spec/fixtures/rubygem.config.xml
299
300
  - spec/fixtures/therubyracer.config.xml
301
+ - spec/hash_key_cleaner_spec.rb
300
302
  - spec/job_config_builder_spec.rb
301
303
  - spec/spec_helper.rb
302
304
  - tasks/upgrade.rake