hudson 0.3.0.beta.11 → 0.3.0.beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hudson (0.3.0.beta.11)
4
+ hudson (0.3.0.beta.12)
5
5
  builder (~> 2.1.2)
6
6
  hpricot
7
7
  httparty (~> 0.6.1)
@@ -3,7 +3,7 @@ Feature: Running a Hudson Server
3
3
  I want to be able to easily control a hudson server
4
4
  In order to spend my time on how the process operates, not how to start stop and control it.
5
5
 
6
- Scenario: Start a Hudson Server
6
+ Scenario: Start a Hudson Server (hudson server)
7
7
  Given env variable $HOME set to project path "home"
8
8
  And "home/.hudson" folder is deleted
9
9
  And there is nothing listening on port 5001
@@ -1,17 +1,17 @@
1
1
  Feature: Listing jobs
2
2
  I want to see the status of jobs on servers I'm interested in
3
3
 
4
- Scenario: List jobs on a non-existent server
4
+ Scenario: List jobs on a non-existent server (hudson list)
5
5
  When I run local executable "hudson" with arguments "list --host localhost --port 9999"
6
6
  Then I should see "localhost:9999 - no connection"
7
7
 
8
- Scenario: List jobs on a server with no jobs
8
+ Scenario: List jobs on a server with no jobs (hudson list)
9
9
  Given I have a Hudson server running
10
10
  And the Hudson server has no current jobs
11
11
  When I run local executable "hudson" with arguments "list --host localhost --port 3010"
12
12
  Then I should see "localhost:3010 - no jobs"
13
13
 
14
- Scenario: List jobs on a server with jobs
14
+ Scenario: List jobs on a server with jobs (hudson list)
15
15
  Given I have a Hudson server running
16
16
  And the Hudson server has no current jobs
17
17
  And I am in the "ruby" project folder
@@ -7,63 +7,92 @@ Feature: Create jobs
7
7
  Given I have a Hudson server running
8
8
  And the Hudson server has no current jobs
9
9
 
10
- Scenario: Discover Ruby project, on git scm, and create job
10
+ Scenario: Setup hudson job for git scm (hudson create)
11
11
  Given I am in the "ruby" project folder
12
12
  And the project uses "git" scm
13
13
  When I run local executable "hudson" with arguments "create . --host localhost --port 3010"
14
- Then I should see "Added project 'ruby' to Hudson."
15
- Then I should see "http://localhost:3010/job/ruby/build"
14
+ Then I should see exactly
15
+ """
16
+ Added ruby project 'ruby' to Hudson.
17
+ Triggering initial build...
18
+ Trigger additional builds via:
19
+ URL: http://localhost:3010/job/ruby/build
20
+ CLI: hudson build ruby
21
+ """
16
22
  When I run local executable "hudson" with arguments "list --host localhost --port 3010"
17
23
  Then I should see "ruby"
18
24
 
19
- Scenario: Create job via $HUDSON_HOST and $HUDSON_PORT
25
+ Scenario: Create job via $HUDSON_HOST and $HUDSON_PORT (hudson create)
20
26
  Given I am in the "ruby" project folder
21
27
  And the project uses "git" scm
22
28
  And env variable $HUDSON_HOST set to "localhost"
23
29
  And env variable $HUDSON_PORT set to "3010"
24
30
  When I run local executable "hudson" with arguments "create ."
25
- Then I should see "Added project 'ruby' to Hudson."
26
31
  Then I should see "http://localhost:3010/job/ruby/build"
27
32
  When I run local executable "hudson" with arguments "list"
28
33
  Then I should see "ruby"
29
34
 
30
- Scenario: Reject projects that don't use bundler
35
+ Scenario: Don't trigger initial job build (hudson create --no-build)
36
+ Given I am in the "ruby" project folder
37
+ And the project uses "git" scm
38
+ When I run local executable "hudson" with arguments "create . --no-build --host localhost --port 3010"
39
+ Then I should see exactly
40
+ """
41
+ Added ruby project 'ruby' to Hudson.
42
+ Trigger builds via:
43
+ URL: http://localhost:3010/job/ruby/build
44
+ CLI: hudson build ruby
45
+ """
46
+
47
+ Scenario: Setup hudson job for a specific node label (hudson create --assigned_node)
48
+ Given I am in the "ruby" project folder
49
+ And the project uses "git" scm
50
+ When I run local executable "hudson" with arguments "create . --assigned_node my_node --host localhost --port 3010"
51
+ Then I should see "Added ruby project 'ruby' to Hudson."
52
+
53
+ Scenario: Select 'rails3' project type (hudson create --template rails3)
54
+ Given I am in the "rails-3" project folder
55
+ And the project uses "git" scm
56
+ When I run local executable "hudson" with arguments "create . --template rails3 --host localhost --port 3010"
57
+ Then I should see "Added rails3 project 'rails-3' to Hudson."
58
+
59
+ Scenario: Reject projects that don't use bundler (hudson create)
31
60
  Given I am in the "non-bundler" project folder
32
61
  And the project uses "git" scm
33
62
  When I run local executable "hudson" with arguments "create . --host localhost --port 3010"
34
63
  Then I should see "Ruby/Rails projects without a Gemfile are currently unsupported."
35
64
 
36
- Scenario: Attempt to create project without scm
65
+ Scenario: Attempt to create project without scm (hudson create)
37
66
  Given I am in the "ruby" project folder
38
67
  When I run local executable "hudson" with arguments "create . --host localhost --port 3010"
39
68
  Then I should see "Cannot determine project SCM. Currently supported:"
40
69
 
41
- Scenario: Trigger a job build
70
+ Scenario: Recreate a job (hudson create --override)
71
+ Given I am in the "ruby" project folder
72
+ When I create a job
73
+ Then I should see "Added ruby project 'ruby' to Hudson."
74
+ When I recreate a job
75
+ Then I should see "Added ruby project 'ruby' to Hudson."
76
+
77
+ Scenario: Trigger a job build (hudson build)
42
78
  Given I am in the "ruby" project folder
43
79
  When I create a job
44
80
  When I run local executable "hudson" with arguments "build"
45
81
  Then I should see "Build for 'ruby' running now..."
46
82
 
47
- Scenario: Trigger a job build on invaild project
83
+ Scenario: Trigger a job build on invaild project (hudson build)
48
84
  Given I am in the "ruby" project folder
49
85
  When I run local executable "hudson" with arguments "build . --host localhost --port 3010"
50
86
  Then I should see "ERROR: No job 'ruby' on server."
51
87
 
52
- Scenario: Recreate a job
53
- Given I am in the "ruby" project folder
54
- When I create a job
55
- Then I should see "Added project 'ruby' to Hudson."
56
- When I recreate a job
57
- Then I should see "Added project 'ruby' to Hudson."
58
-
59
- Scenario: Remove a job
88
+ Scenario: Remove a job (hudson remove)
60
89
  Given I am in the "ruby" project folder
61
90
  When I create a job
62
- Then I should see "Added project 'ruby' to Hudson."
91
+ Then I should see "Added ruby project 'ruby' to Hudson."
63
92
  When I run local executable "hudson" with arguments "remove ."
64
93
  Then I should see "Removed project 'ruby' from Hudson."
65
94
 
66
- Scenario: Remove a job that doesn't exist gives error
95
+ Scenario: Remove a job that doesn't exist gives error (hudson remove)
67
96
  Given I am in the "ruby" project folder
68
97
  When I run local executable "hudson" with arguments "remove . --host localhost --port 3010"
69
98
  Then I should see "ERROR: Failed to delete project 'ruby'."
@@ -7,7 +7,7 @@ Feature: Adding slave nodes
7
7
  Given I have a Hudson server running
8
8
  And the Hudson server has no slaves
9
9
 
10
- Scenario: Add a slave with no authentication required
10
+ Scenario: List available slaves (hudson nodes)
11
11
  When I run local executable "hudson" with arguments "nodes --host localhost --port 3010"
12
12
  Then I should see exactly
13
13
  """
@@ -19,7 +19,7 @@ Feature: Adding slave nodes
19
19
  | label | app1 app2 app3 |
20
20
  | slave_host | foo1.bar.com |
21
21
  | slave_user | hudson |
22
- When I run local executable "hudson" with arguments "nodes --host localhost --port 3010"
22
+ When I run local executable "hudson" with arguments "nodes"
23
23
  Then I should see exactly
24
24
  """
25
25
  master
@@ -9,4 +9,5 @@ Before do
9
9
  FileUtils.rm_rf @tmp_root
10
10
  FileUtils.mkdir_p @home_path
11
11
  ENV['HOME'] = @home_path
12
+ ENV['CUCUMBER_RUNNING'] = 'oooh yes'
12
13
  end
data/hudson.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{hudson}
5
- s.version = "0.3.0.beta.11"
5
+ s.version = "0.3.0.beta.12"
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"]
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
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/listing_jobs.feature", "features/manage_jobs.feature", "features/manage_remote_servers.feature", "features/manage_slave_nodes.feature", "features/server.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/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/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_remote_servers.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/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/rubygem.config.xml", "spec/fixtures/therubyracer.config.xml", "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/cli.rb CHANGED
@@ -42,14 +42,16 @@ module Hudson
42
42
  cmd << "--logfile=#{File.expand_path(options[:logfile])}" if options[:logfile]
43
43
  cmd << "--httpPort=#{options[:port]}"
44
44
  cmd << "--controlPort=#{options[:control]}"
45
- puts cmd.join(" ")
45
+ shell.say cmd.join(" ")
46
46
  exec(*cmd)
47
47
  end
48
48
 
49
49
  desc "create project_path [options]", "create a build for your project"
50
50
  common_options
51
+ method_option :"no-build", :desc => "create job without initial build", :type => :boolean, :default => false
51
52
  method_option :override, :desc => "override if job exists", :type => :boolean, :default => false
52
53
  method_option :assigned_node, :desc => "only use slave nodes with this label"
54
+ method_option :template, :desc => "template of job steps (available: #{JobConfigBuilder::VALID_JOB_TEMPLATES.join ','})", :default => 'ruby'
53
55
  def create(project_path)
54
56
  select_hudson_server(options)
55
57
  FileUtils.chdir(project_path) do
@@ -59,21 +61,32 @@ module Hudson
59
61
  unless File.exists?("Gemfile")
60
62
  error "Ruby/Rails projects without a Gemfile are currently unsupported."
61
63
  end
62
- job_config = Hudson::JobConfigBuilder.new(:rails) do |c|
63
- c.scm = scm.url
64
- c.assigned_node = options[:assigned_node] if options[:assigned_node]
65
- end
66
- name = File.basename(FileUtils.pwd)
67
64
  begin
65
+ template = options[:template]
66
+ job_config = Hudson::JobConfigBuilder.new(template) do |c|
67
+ c.scm = scm.url
68
+ c.assigned_node = options[:assigned_node] if options[:assigned_node]
69
+ end
70
+ name = File.basename(FileUtils.pwd)
68
71
  if Hudson::Api.create_job(name, job_config, options)
69
72
  build_url = "#{@uri}/job/#{name.gsub(/\s/,'%20')}/build"
70
- puts "Added project '#{name}' to Hudson."
71
- puts "Trigger builds via: #{build_url}"
73
+ shell.say "Added #{template} project '#{name}' to Hudson.", :green
74
+ unless options[:"no-build"]
75
+ shell.say "Triggering initial build..."
76
+ Hudson::Api.build_job(name)
77
+ shell.say "Trigger additional builds via:"
78
+ else
79
+ shell.say "Trigger builds via:"
80
+ end
81
+ shell.say " URL: "; shell.say "#{build_url}", :yellow
82
+ shell.say " CLI: "; shell.say "#{cmd} build #{name}", :yellow
72
83
  else
73
84
  error "Failed to create project '#{name}'"
74
85
  end
86
+ rescue Hudson::JobConfigBuilder::InvalidTemplate
87
+ error "Invalid job template '#{template}'."
75
88
  rescue Hudson::Api::JobAlreadyExistsError
76
- error "Job '#{name} already exists."
89
+ error "Job '#{name}' already exists."
77
90
  end
78
91
  end
79
92
  end
@@ -85,7 +98,7 @@ module Hudson
85
98
  FileUtils.chdir(project_path) do
86
99
  name = File.basename(FileUtils.pwd)
87
100
  if Hudson::Api.build_job(name)
88
- puts "Build for '#{name}' running now..."
101
+ shell.say "Build for '#{name}' running now..."
89
102
  else
90
103
  error "No job '#{name}' on server."
91
104
  end
@@ -99,7 +112,7 @@ module Hudson
99
112
  FileUtils.chdir(project_path) do
100
113
  name = File.basename(FileUtils.pwd)
101
114
  if Hudson::Api.delete_job(name)
102
- puts "Removed project '#{name}' from Hudson."
115
+ shell.say "Removed project '#{name}' from Hudson."
103
116
  else
104
117
  error "Failed to delete project '#{name}'."
105
118
  end
@@ -206,5 +219,9 @@ USEAGE
206
219
  shell.say "ERROR: #{text}", :red
207
220
  exit
208
221
  end
222
+
223
+ def cmd
224
+ ENV['CUCUMBER_RUNNING'] ? 'hudson' : $0
225
+ end
209
226
  end
210
227
  end
@@ -5,14 +5,15 @@ module Hudson
5
5
  attr_accessor :scm, :git_branches
6
6
  attr_accessor :job_type, :matrix_project
7
7
  attr_accessor :assigned_node
8
-
8
+
9
+ InvalidTemplate = Class.new(StandardError)
10
+
9
11
  def initialize(options = nil, &block)
10
- if options.is_a?(Symbol)
12
+ if options.is_a?(String) || options.is_a?(Symbol)
11
13
  @job_type = options.to_s
12
14
  elsif options.is_a?(Hash)
13
15
  @job_type = options[:job_type].to_s
14
16
  end
15
- @matrix_project = %w[rubygem].include? job_type
16
17
  yield self
17
18
  @git_branches ||= ["**"]
18
19
  end
@@ -32,11 +33,11 @@ module Hudson
32
33
  b.blockBuildWhenUpstreamBuilding false
33
34
  # build_triggers b
34
35
  b.concurrentBuild false
35
- build_axes b if matrix_project
36
+ build_axes b if matrix_project?
36
37
  build_steps b
37
38
  b.publishers
38
39
  b.buildWrappers
39
- b.runSequentially false if matrix_project
40
+ b.runSequentially false if matrix_project?
40
41
  end
41
42
  end
42
43
 
@@ -45,6 +46,10 @@ module Hudson
45
46
  end
46
47
 
47
48
  protected
49
+
50
+ def matrix_project?
51
+ %w[ruby].include? job_type
52
+ end
48
53
 
49
54
  # <scm class="hudson.plugins.git.GitSCM"> ... </scm>
50
55
  def build_scm(b)
@@ -112,10 +117,14 @@ module Hudson
112
117
  def build_axes(b)
113
118
  b.axes
114
119
  end
115
-
120
+
121
+ # TODO modularise this
122
+ # TODO how to customize? e.g. EngineYard template?
123
+ VALID_JOB_TEMPLATES = %w[rails rails3 ruby rubygem]
116
124
  def build_steps(b)
117
125
  b.builders do
118
- if job_type == "rails"
126
+ raise InvalidTemplate unless VALID_JOB_TEMPLATES.include?(job_type)
127
+ if job_type == "rails3"
119
128
  build_shell_step b, "bundle install"
120
129
  build_ruby_step b, <<-RUBY.gsub(/^ /, '')
121
130
  unless File.exist?("config/database.yml")
@@ -127,8 +136,12 @@ module Hudson
127
136
  RUBY
128
137
  build_shell_step b, "bundle exec rake db:schema:load"
129
138
  build_shell_step b, "bundle exec rake"
139
+ elsif job_type == "ruby"
140
+ build_shell_step b, "bundle install"
141
+ build_shell_step b, "bundle exec rake"
130
142
  elsif job_type == "rubygem"
131
- build_rake_step b, "features"
143
+ build_shell_step b, "bundle install"
144
+ build_shell_step b, "bundle exec rake"
132
145
  end
133
146
  end
134
147
  end
@@ -1,3 +1,3 @@
1
1
  module Hudson
2
- VERSION = "0.3.0.beta.11"
2
+ VERSION = "0.3.0.beta.12"
3
3
  end
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: 62196357
4
+ hash: 62196363
5
5
  prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
9
  - 0
10
10
  - beta
11
- - 11
12
- version: 0.3.0.beta.11
11
+ - 12
12
+ version: 0.3.0.beta.12
13
13
  platform: ruby
14
14
  authors:
15
15
  - Charles Lowell
@@ -206,11 +206,11 @@ extra_rdoc_files: []
206
206
  files:
207
207
  - bin/hudson
208
208
  - features/development.feature
209
+ - features/launch_server.feature
209
210
  - features/listing_jobs.feature
210
211
  - features/manage_jobs.feature
211
212
  - features/manage_remote_servers.feature
212
213
  - features/manage_slave_nodes.feature
213
- - features/server.feature
214
214
  - features/step_definitions/common_steps.rb
215
215
  - features/step_definitions/fixture_project_steps.rb
216
216
  - features/step_definitions/hudson_steps.rb