hudson 0.3.0.beta.6 → 0.3.0.beta.7

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.5)
4
+ hudson (0.3.0.beta.7)
5
5
  builder (~> 2.1.2)
6
6
  hpricot
7
7
  httparty (~> 0.5.2)
@@ -32,6 +32,17 @@ Feature: Create jobs
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
34
 
35
+ Scenario: Trigger a job build
36
+ Given I am in the "ruby" project folder
37
+ When I create a job
38
+ When I run local executable "hudson" with arguments "build"
39
+ Then I should see "Build for 'ruby' running now..."
40
+
41
+ Scenario: Trigger a job build on invaild project
42
+ Given I am in the "ruby" project folder
43
+ When I run local executable "hudson" with arguments "build . --host localhost --port 3010"
44
+ Then I should see "ERROR: No job 'ruby' on server."
45
+
35
46
  Scenario: Recreate a job
36
47
  Given I am in the "ruby" project folder
37
48
  When I create a job
@@ -43,7 +54,7 @@ Feature: Create jobs
43
54
  Given I am in the "ruby" project folder
44
55
  When I create a job
45
56
  Then I should see "Added project 'ruby' to Hudson."
46
- When I run local executable "hudson" with arguments "remove . --host localhost --port 3010"
57
+ When I run local executable "hudson" with arguments "remove ."
47
58
  Then I should see "Removed project 'ruby' from Hudson."
48
59
 
49
60
  Scenario: Remove a job that doesn't exist gives error
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.6"
5
+ s.version = "0.3.0.beta.7"
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
@@ -1,5 +1,5 @@
1
1
  module Hudson
2
- VERSION = "0.3.0.beta.6"
2
+ VERSION = "0.3.0.beta.7"
3
3
  HUDSON_VERSION = "1.380"
4
4
  WAR = File.expand_path(File.dirname(__FILE__) + "/hudson/hudson.war")
5
5
  PLUGINS = File.expand_path(File.dirname(__FILE__) + "/hudson/plugins")
data/lib/hudson/api.rb CHANGED
@@ -43,7 +43,7 @@ module Hudson
43
43
  cache_base_uri
44
44
  true
45
45
  else
46
- puts res.body
46
+ p res.code
47
47
  if res.body =~ /A job already exists with the name/
48
48
  if options[:override]
49
49
  delete_job(name)
@@ -52,9 +52,13 @@ module Hudson
52
52
  raise JobAlreadyExistsError.new(name)
53
53
  end
54
54
  else
55
- require "hpricot"
56
55
  puts "Server error:"
57
- puts Hpricot(res.body).search("//body").text
56
+ begin
57
+ require "hpricot"
58
+ puts Hpricot(res.body).search("//body").text
59
+ rescue
60
+ puts res.body
61
+ end
58
62
  end
59
63
  false
60
64
  end
@@ -62,8 +66,12 @@ module Hudson
62
66
 
63
67
  # Attempts to delete a job +name+
64
68
  def self.delete_job(name)
65
- uri = URI.parse base_uri
66
- res = Net::HTTP.start(uri.host, uri.port) { |http| http.post("#{job_url name}/doDelete", {}) }
69
+ res = post_plain "#{job_url name}/doDelete"
70
+ res.code.to_i == 302
71
+ end
72
+
73
+ def self.build_job(name)
74
+ res = get_plain "/job/#{name}/build"
67
75
  res.code.to_i == 302
68
76
  end
69
77
 
@@ -151,6 +159,16 @@ module Hudson
151
159
  end
152
160
  end
153
161
 
162
+ def self.post_plain(path, options = {})
163
+ uri = URI.parse base_uri
164
+ res = Net::HTTP.start(uri.host, uri.port) { |http| http.post(path, options) }
165
+ end
166
+
167
+ def self.get_plain(path, options = {})
168
+ uri = URI.parse base_uri
169
+ res = Net::HTTP.start(uri.host, uri.port) { |http| http.get(path, options) }
170
+ end
171
+
154
172
  private
155
173
  def self.cache_base_uri
156
174
  Hudson::Config.config["base_uri"] = base_uri
data/lib/hudson/cli.rb CHANGED
@@ -69,6 +69,20 @@ module Hudson
69
69
  end
70
70
  end
71
71
 
72
+ desc "build [PROJECT_PATH]", "trigger build of this project's build job"
73
+ common_options
74
+ def build(project_path = ".")
75
+ select_hudson_server(options)
76
+ FileUtils.chdir(project_path) do
77
+ name = File.basename(FileUtils.pwd)
78
+ if Hudson::Api.build_job(name)
79
+ puts "Build for '#{name}' running now..."
80
+ else
81
+ error "No job '#{name}' on server."
82
+ end
83
+ end
84
+ end
85
+
72
86
  desc "remove PROJECT_PATH", "remove this project's build job from Hudson"
73
87
  common_options
74
88
  def remove(project_path)
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: 62196383
4
+ hash: 62196381
5
5
  prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
9
  - 0
10
10
  - beta
11
- - 6
12
- version: 0.3.0.beta.6
11
+ - 7
12
+ version: 0.3.0.beta.7
13
13
  platform: ruby
14
14
  authors:
15
15
  - Charles Lowell