hudson 0.3.0.beta.1 → 0.3.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/hudson CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
3
  $:.unshift(File.expand_path(File.dirname(File.dirname(__FILE__) + "/../lib/hudson.rb")))
4
- require File.dirname(__FILE__) + '/../lib/hudson'
4
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/hudson')
5
5
  require 'hudson/cli'
6
6
 
7
7
  Hudson::CLI.start
@@ -0,0 +1,197 @@
1
+ !RBIX
2
+ 0
3
+ x
4
+ M
5
+ 1
6
+ n
7
+ n
8
+ x
9
+ 10
10
+ __script__
11
+ i
12
+ 89
13
+ 5
14
+ 7
15
+ 0
16
+ 64
17
+ 47
18
+ 49
19
+ 1
20
+ 1
21
+ 15
22
+ 99
23
+ 43
24
+ 2
25
+ 7
26
+ 3
27
+ 49
28
+ 4
29
+ 1
30
+ 45
31
+ 5
32
+ 6
33
+ 45
34
+ 5
35
+ 7
36
+ 45
37
+ 5
38
+ 8
39
+ 65
40
+ 49
41
+ 9
42
+ 0
43
+ 49
44
+ 10
45
+ 1
46
+ 7
47
+ 11
48
+ 64
49
+ 81
50
+ 12
51
+ 49
52
+ 10
53
+ 1
54
+ 49
55
+ 13
56
+ 1
57
+ 49
58
+ 14
59
+ 1
60
+ 15
61
+ 5
62
+ 45
63
+ 5
64
+ 15
65
+ 65
66
+ 49
67
+ 9
68
+ 0
69
+ 49
70
+ 10
71
+ 1
72
+ 7
73
+ 16
74
+ 64
75
+ 81
76
+ 12
77
+ 47
78
+ 49
79
+ 1
80
+ 1
81
+ 15
82
+ 5
83
+ 7
84
+ 17
85
+ 64
86
+ 47
87
+ 49
88
+ 1
89
+ 1
90
+ 15
91
+ 45
92
+ 18
93
+ 19
94
+ 43
95
+ 20
96
+ 49
97
+ 21
98
+ 0
99
+ 15
100
+ 2
101
+ 11
102
+ I
103
+ 5
104
+ I
105
+ 0
106
+ I
107
+ 0
108
+ I
109
+ 0
110
+ n
111
+ p
112
+ 22
113
+ s
114
+ 8
115
+ rubygems
116
+ x
117
+ 7
118
+ require
119
+ x
120
+ 7
121
+ Globals
122
+ x
123
+ 2
124
+ $:
125
+ x
126
+ 2
127
+ []
128
+ x
129
+ 4
130
+ File
131
+ n
132
+ n
133
+ n
134
+ x
135
+ 11
136
+ active_path
137
+ x
138
+ 7
139
+ dirname
140
+ s
141
+ 17
142
+ /../lib/hudson.rb
143
+ x
144
+ 1
145
+ +
146
+ x
147
+ 11
148
+ expand_path
149
+ x
150
+ 7
151
+ unshift
152
+ n
153
+ s
154
+ 14
155
+ /../lib/hudson
156
+ s
157
+ 10
158
+ hudson/cli
159
+ x
160
+ 6
161
+ Hudson
162
+ n
163
+ x
164
+ 3
165
+ CLI
166
+ x
167
+ 5
168
+ start
169
+ p
170
+ 11
171
+ I
172
+ 0
173
+ I
174
+ 2
175
+ I
176
+ 9
177
+ I
178
+ 3
179
+ I
180
+ 30
181
+ I
182
+ 4
183
+ I
184
+ 45
185
+ I
186
+ 5
187
+ I
188
+ 4e
189
+ I
190
+ 7
191
+ I
192
+ 59
193
+ x
194
+ 47
195
+ /Users/drnic/Projects/gems/hudson.rb/bin/hudson
196
+ p
197
+ 0
@@ -0,0 +1,27 @@
1
+ Feature: Adding slave nodes
2
+ In order to have different environments for different projects
3
+ As a developer
4
+ I want to add new slave nodes to my Hudson instance
5
+
6
+ Background:
7
+ Given I have a Hudson server running
8
+ And the Hudson server has no slaves
9
+
10
+ Scenario: Add a slave with no authentication required
11
+ When I run local executable "hudson" with arguments "nodes --host localhost --port 3010"
12
+ Then I should see exactly
13
+ """
14
+ master
15
+ """
16
+
17
+ When I create a new node with the following options on "http://localhost:3010":
18
+ | name | Slave 1 |
19
+ | label | app1 app2 app3 |
20
+ | slave_host | foo1.bar.com |
21
+ | slave_user | hudson |
22
+ When I run local executable "hudson" with arguments "nodes --host localhost --port 3010"
23
+ Then I should see exactly
24
+ """
25
+ master
26
+ Slave 1
27
+ """
@@ -2,13 +2,13 @@ Feature: Listing jobs
2
2
  I want to see the status of jobs on servers I'm interested in
3
3
 
4
4
  Scenario: List jobs on a non-existent server
5
- When I run local executable "hudson" with arguments "list test --host localhost --port 9999"
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
8
  Scenario: List jobs on a server with no jobs
9
9
  Given I have a Hudson server running
10
10
  And the Hudson server has no current jobs
11
- When I run local executable "hudson" with arguments "list test --host localhost --port 3010"
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
14
  Scenario: List jobs on a server with jobs
@@ -18,7 +18,7 @@ When /^I invoke "(.*)" generator with arguments "(.*)"$/ do |generator, argument
18
18
  in_project_folder do
19
19
  if Object.const_defined?("APP_ROOT")
20
20
  APP_ROOT.replace(FileUtils.pwd)
21
- else
21
+ else
22
22
  APP_ROOT = FileUtils.pwd
23
23
  end
24
24
  run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
@@ -32,14 +32,14 @@ end
32
32
  When /^I run executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
33
33
  @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
34
34
  in_project_folder do
35
- system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
35
+ system "#{executable.inspect} #{arguments} > #{@stdout.inspect} 2> #{@stdout.inspect}"
36
36
  end
37
37
  end
38
38
 
39
39
  When /^I run project executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
40
40
  @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
41
41
  in_project_folder do
42
- system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
42
+ system "ruby #{executable.inspect} #{arguments} > #{@stdout.inspect} 2> #{@stdout.inspect}"
43
43
  end
44
44
  end
45
45
 
@@ -47,14 +47,14 @@ When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, argu
47
47
  @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
48
48
  executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
49
49
  in_project_folder do
50
- system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
50
+ system "ruby #{executable.inspect} #{arguments} > #{@stdout.inspect} 2> #{@stdout.inspect}"
51
51
  end
52
52
  end
53
53
 
54
54
  When /^I invoke task "rake (.*)"/ do |task|
55
55
  @stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
56
56
  in_project_folder do
57
- system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
57
+ system "rake #{task} --trace > #{@stdout.inspect} 2> #{@stdout.inspect}"
58
58
  end
59
59
  end
60
60
 
@@ -94,52 +94,52 @@ Then /gem file "(.*)" and generated file "(.*)" should be the same/ do |gem_file
94
94
  end
95
95
 
96
96
  Then /^(does|does not) invoke generator "(.*)"$/ do |does_invoke, generator|
97
- actual_output = File.read(@stdout)
97
+ actual_output = get_command_output
98
98
  does_invoke == "does" ?
99
99
  actual_output.should(match(/dependency\s+#{generator}/)) :
100
100
  actual_output.should_not(match(/dependency\s+#{generator}/))
101
101
  end
102
102
 
103
103
  Then /help options "(.*)" and "(.*)" are displayed/ do |opt1, opt2|
104
- actual_output = File.read(@stdout)
104
+ actual_output = get_command_output
105
105
  actual_output.should match(/#{opt1}/)
106
106
  actual_output.should match(/#{opt2}/)
107
107
  end
108
108
 
109
109
  Then /^I should see "([^\"]*)"$/ do |text|
110
- actual_output = File.read(@stdout)
110
+ actual_output = get_command_output
111
111
  actual_output.should contain(text)
112
112
  end
113
113
 
114
114
  Then /^I should not see "([^\"]*)"$/ do |text|
115
- actual_output = File.read(@stdout)
115
+ actual_output =
116
116
  actual_output.should_not contain(text)
117
117
  end
118
118
 
119
119
  Then /^I should see$/ do |text|
120
- actual_output = File.read(@stdout)
120
+ actual_output = get_command_output
121
121
  actual_output.should contain(text)
122
122
  end
123
123
 
124
124
  Then /^I should not see$/ do |text|
125
- actual_output = File.read(@stdout)
125
+ actual_output = get_command_output
126
126
  actual_output.should_not contain(text)
127
127
  end
128
128
 
129
129
  Then /^I should see exactly$/ do |text|
130
- actual_output = File.read(@stdout)
130
+ actual_output = get_command_output
131
131
  actual_output.should == text
132
132
  end
133
133
 
134
134
  Then /^I should see all (\d+) tests pass/ do |expected_test_count|
135
135
  expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
136
- actual_output = File.read(@stdout)
136
+ actual_output = get_command_output
137
137
  actual_output.should match(expected)
138
138
  end
139
139
 
140
140
  Then /^I should see all (\d+) examples pass/ do |expected_test_count|
141
141
  expected = %r{^#{expected_test_count} examples?, 0 failures}
142
- actual_output = File.read(@stdout)
142
+ actual_output = get_command_output
143
143
  actual_output.should match(expected)
144
144
  end
145
145
 
@@ -153,15 +153,15 @@ end
153
153
  Then /^Rakefile can display tasks successfully/ do
154
154
  @stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
155
155
  in_project_folder do
156
- system "rake -T > #{@stdout} 2> #{@stdout}"
156
+ system "rake -T > #{@stdout.inspect} 2> #{@stdout.inspect}"
157
157
  end
158
- actual_output = File.read(@stdout)
158
+ actual_output = get_command_output
159
159
  actual_output.should match(/^rake\s+\w+\s+#\s.*/)
160
160
  end
161
161
 
162
162
  Then /^task "rake (.*)" is executed successfully/ do |task|
163
163
  @stdout.should_not be_nil
164
- actual_output = File.read(@stdout)
164
+ actual_output = get_command_output
165
165
  actual_output.should_not match(/^Don't know how to build task '#{task}'/)
166
166
  actual_output.should_not match(/Error/i)
167
167
  end
@@ -179,3 +179,13 @@ Then /^the file "([^\"]*)" is a valid gemspec$/ do |filename|
179
179
  spec = eval(File.read(filename))
180
180
  spec.validate
181
181
  end
182
+
183
+ When /^I create a new node with the following options on "http:\/\/(.+?):(\d+)":$/ do |host, port, table|
184
+ options = table.raw.inject({}) do |options, (key, value)|
185
+ options[(key.to_sym rescue key) || key] = value
186
+ options
187
+ end
188
+
189
+ Hudson::Api.setup_base_url(:host => host, :port => port.to_i)
190
+ Hudson::Api.add_node(options)
191
+ end
@@ -29,6 +29,26 @@ Given /^the Hudson server has no current jobs$/ do
29
29
  end
30
30
  end
31
31
 
32
+ Given /^the Hudson server has no slaves$/ do
33
+ if port = @hudson_port
34
+ require "open-uri"
35
+ require "yajl"
36
+ base_url = "http://#{@hudson_host}:#{@hudson_port}"
37
+ hudson_info = Yajl::Parser.new.parse(open("#{base_url}/computer/api/json"))
38
+
39
+ hudson_info['computer'].each do |node|
40
+ name = node["displayName"]
41
+ next if name == "master"
42
+ job_url = "#{base_url}/computer/#{CGI::escape(name).gsub('+', '%20')}"
43
+ res = Net::HTTP.start("localhost", port) { |http| http.post("#{job_url}/doDelete/api/json", {}) }
44
+ end
45
+ hudson_info = Yajl::Parser.new.parse(open("http://#{@hudson_host}:#{@hudson_port}/api/json"))
46
+ hudson_info['jobs'].should == []
47
+ else
48
+ puts "WARNING: Run 'I have a Hudson server running' step first."
49
+ end
50
+ end
51
+
32
52
  Given /^there is nothing listening on port (\d+)$/ do |port|
33
53
  lambda {
34
54
  TCPSocket.open("localhost", port) {}
@@ -56,7 +76,7 @@ When /^I run hudson server with arguments "(.*)"/ do |arguments|
56
76
  @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
57
77
  executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin","hudson"))
58
78
  in_project_folder do
59
- system "ruby #{executable} server #{arguments} > #{@stdout} 2>#{@stdout}"
79
+ system "ruby #{executable.inspect} server #{arguments} > #{@stdout.inspect} 2> #{@stdout.inspect}"
60
80
  end
61
81
  end
62
82
 
@@ -1,4 +1,12 @@
1
1
  module CommonHelpers
2
+ def get_command_output
3
+ strip_color_codes(File.read(@stdout)).chomp
4
+ end
5
+
6
+ def strip_color_codes(text)
7
+ text.gsub(/\e\[\d+m/, '')
8
+ end
9
+
2
10
  def in_tmp_folder(&block)
3
11
  FileUtils.chdir(@tmp_root, &block)
4
12
  end
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.1"
5
+ s.version = "0.3.0.beta.2"
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-10-11}
9
+ s.date = %q{2010-10-27}
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/create_jobs.feature", "features/development.feature", "features/fixtures", "features/fixtures/projects", "features/fixtures/projects/ruby", "features/fixtures/projects/ruby/Rakefile", "features/listing_jobs.feature", "features/managing_remote_servers.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", "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/hudson-cli.jar", "lib/hudson/hudson.war", "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.rb", "Rakefile", "README.md", "spec", "spec/fixtures", "spec/fixtures/ec2_global.config.xml", "spec/fixtures/rails.multi.config.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"]
14
+ s.files = ["bin", "bin/hudson", "bin/hudson.compiled.rbc", "features", "features/adding_slave_nodes.feature", "features/create_jobs.feature", "features/development.feature", "features/fixtures", "features/fixtures/projects", "features/fixtures/projects/ruby", "features/fixtures/projects/ruby/Rakefile", "features/listing_jobs.feature", "features/managing_remote_servers.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", "Gemfile", "Gemfile.lock", "hudson.gemspec", "lib", "lib/hudson", "lib/hudson/api.rb", "lib/hudson/api.rbc", "lib/hudson/cli", "lib/hudson/cli/formatting.rb", "lib/hudson/cli.rb", "lib/hudson/config.rb", "lib/hudson/hudson-cli.jar", "lib/hudson/hudson.war", "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.rb", "lib/hudson.rbc", "Rakefile", "README.md", "spec", "spec/fixtures", "spec/fixtures/ec2_global.config.xml", "spec/fixtures/rails.multi.config.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"]
15
15
  s.homepage = %q{http://github.com/cowboyd/hudson.rb}
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{hudson}