hudson 0.3.0.beta.4 → 0.3.0.beta.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/features/create_jobs.feature +10 -0
- data/features/step_definitions/hudson_steps.rb +10 -0
- data/features/step_definitions/scm_steps.rb +6 -4
- data/hudson.gemspec +1 -1
- data/lib/hudson.rb +1 -1
- data/lib/hudson/api.rb +28 -4
- data/lib/hudson/cli.rb +2 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hudson (0.3.0.beta.
|
4
|
+
hudson (0.3.0.beta.5)
|
5
5
|
builder (~> 2.1.2)
|
6
6
|
hpricot
|
7
7
|
httparty (~> 0.5.2)
|
@@ -56,7 +56,7 @@ DEPENDENCIES
|
|
56
56
|
hudson!
|
57
57
|
json (~> 1.4.0)
|
58
58
|
rake (~> 0.8.7)
|
59
|
-
rspec (~> 2.0.0
|
59
|
+
rspec (~> 2.0.0)
|
60
60
|
term-ansicolor (>= 1.0.4)
|
61
61
|
thor (= 0.14.2)
|
62
62
|
yajl-ruby (>= 0.7.6)
|
@@ -31,3 +31,13 @@ Feature: Create jobs
|
|
31
31
|
Given I am in the "ruby" project folder
|
32
32
|
When I run local executable "hudson" with arguments "create . --host localhost --port 3010"
|
33
33
|
Then I should see "Cannot determine project SCM. Currently supported:"
|
34
|
+
|
35
|
+
Scenario: Recreate job
|
36
|
+
Given I am in the "ruby" project folder
|
37
|
+
When I create a job
|
38
|
+
Then I should see "Added project 'ruby' to Hudson."
|
39
|
+
When I recreate a job
|
40
|
+
Then I should see "Added project 'ruby' to Hudson."
|
41
|
+
|
42
|
+
|
43
|
+
|
@@ -89,3 +89,13 @@ Then /^I should see a hudson server on port (\d+)$/ do |port|
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
+
When /^I (re|)create a job$/ do |override|
|
93
|
+
override = override.blank? ? "" : " --override"
|
94
|
+
steps <<-CUCUMBER
|
95
|
+
When the project uses "git" scm
|
96
|
+
When I run local executable "hudson" with arguments "create . --host localhost --port 3010#{override}"
|
97
|
+
CUCUMBER
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
|
@@ -1,10 +1,12 @@
|
|
1
1
|
Given /^the project uses "git" scm$/ do
|
2
2
|
repo = "git://some.host/drnic/ruby.git"
|
3
3
|
in_project_folder do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
unless File.exist?(".git")
|
5
|
+
%x[ git init ]
|
6
|
+
%x[ git add . ]
|
7
|
+
%x[ git commit -m "initial commit" ]
|
8
|
+
%x[ git remote add origin #{repo} ]
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
10
12
|
|
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.
|
5
|
+
s.version = "0.3.0.beta.5"
|
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"]
|
data/lib/hudson.rb
CHANGED
data/lib/hudson/api.rb
CHANGED
@@ -12,6 +12,8 @@ module Hudson
|
|
12
12
|
headers 'content-type' => 'application/json'
|
13
13
|
format :json
|
14
14
|
# http_proxy 'localhost', '8888'
|
15
|
+
|
16
|
+
JobAlreadyExistsError = Class.new(Exception)
|
15
17
|
|
16
18
|
def self.setup_base_url(options)
|
17
19
|
# Thor's HashWithIndifferentAccess is based on string keys which URI::HTTP.build ignores
|
@@ -26,7 +28,14 @@ module Hudson
|
|
26
28
|
end
|
27
29
|
|
28
30
|
# returns true if successfully create a new job on Hudson
|
29
|
-
|
31
|
+
# +job_config+ is a Hudson::JobConfigBuilder instance
|
32
|
+
# +options+ are:
|
33
|
+
# :override - true, will delete any existing job with same name, else error
|
34
|
+
#
|
35
|
+
# returns true if successful, else false
|
36
|
+
#
|
37
|
+
# TODO Exceptions?
|
38
|
+
def self.create_job(name, job_config, options = {})
|
30
39
|
res = post "/createItem/api/xml?name=#{CGI.escape(name)}", {
|
31
40
|
:body => job_config.to_xml, :format => :xml, :headers => { 'content-type' => 'application/xml' }
|
32
41
|
}
|
@@ -34,12 +43,27 @@ module Hudson
|
|
34
43
|
cache_base_uri
|
35
44
|
true
|
36
45
|
else
|
37
|
-
|
38
|
-
|
39
|
-
|
46
|
+
if res.body =~ /A job already exists with the name/
|
47
|
+
if options[:override]
|
48
|
+
delete_job(name)
|
49
|
+
return create_job(name, job_config)
|
50
|
+
else
|
51
|
+
raise JobAlreadyExistsError.new(name)
|
52
|
+
end
|
53
|
+
else
|
54
|
+
require "hpricot"
|
55
|
+
puts "Server error:"
|
56
|
+
puts Hpricot(res.body).search("//body").text
|
57
|
+
end
|
40
58
|
false
|
41
59
|
end
|
42
60
|
end
|
61
|
+
|
62
|
+
# Attempts to delete a job +name+
|
63
|
+
def self.delete_job(name)
|
64
|
+
post "/job/#{name}/doDelete/api/json"
|
65
|
+
rescue Crack::ParseError
|
66
|
+
end
|
43
67
|
|
44
68
|
def self.summary
|
45
69
|
begin
|
data/lib/hudson/cli.rb
CHANGED
@@ -49,6 +49,7 @@ module Hudson
|
|
49
49
|
desc "create [project_path] [options]", "create a continuous build for your project"
|
50
50
|
common_options
|
51
51
|
method_option :name, :banner => "dir_name", :desc => "name of the build"
|
52
|
+
method_option :override, :desc => "override if job exists", :type => :boolean, :default => false
|
52
53
|
def create(project_path = ".")
|
53
54
|
select_hudson_server(options)
|
54
55
|
FileUtils.chdir(project_path) do
|
@@ -59,7 +60,7 @@ module Hudson
|
|
59
60
|
c.scm = scm.url
|
60
61
|
end
|
61
62
|
name = options[:name] || File.basename(FileUtils.pwd)
|
62
|
-
if Hudson::Api.create_job(name, job_config)
|
63
|
+
if Hudson::Api.create_job(name, job_config, {:override => options[:override]})
|
63
64
|
build_url = "#{@uri}/job/#{name.gsub(/\s/,'%20')}/build"
|
64
65
|
puts "Added project '#{name}' to Hudson."
|
65
66
|
puts "Trigger builds via: #{build_url}"
|
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:
|
4
|
+
hash: 62196377
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 0.3.0.beta.
|
11
|
+
- 5
|
12
|
+
version: 0.3.0.beta.5
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Charles Lowell
|