hudson-remote-api 0.7.0 → 1.0.0

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.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/Gemfile +9 -0
  4. data/Gemfile.lock +20 -0
  5. data/README.md +11 -9
  6. data/Rakefile +10 -0
  7. data/fixtures/vcr_cassettes/TestHudsonBuildQueue_test_list.yml +38 -0
  8. data/fixtures/vcr_cassettes/TestHudsonBuild_setup.yml +407 -0
  9. data/fixtures/vcr_cassettes/TestHudsonBuild_test_build_info.yml +222 -0
  10. data/fixtures/vcr_cassettes/TestHudsonClient_test_build_job_.yml +52 -0
  11. data/fixtures/vcr_cassettes/TestHudsonClient_test_build_job_with_parameters_.yml +52 -0
  12. data/fixtures/vcr_cassettes/TestHudsonClient_test_build_queue_info.yml +38 -0
  13. data/fixtures/vcr_cassettes/TestHudsonClient_test_create_item_.yml +52 -0
  14. data/fixtures/vcr_cassettes/TestHudsonClient_test_delete_job_.yml +52 -0
  15. data/fixtures/vcr_cassettes/TestHudsonClient_test_job_build_info.yml +39 -0
  16. data/fixtures/vcr_cassettes/TestHudsonClient_test_job_config_info.yml +48 -0
  17. data/fixtures/vcr_cassettes/TestHudsonJob_test_build.yml +409 -0
  18. data/fixtures/vcr_cassettes/TestHudsonJob_test_build_with_params.yml +189 -0
  19. data/fixtures/vcr_cassettes/TestHudsonJob_test_builds_list.yml +192 -0
  20. data/fixtures/vcr_cassettes/TestHudsonJob_test_copy.yml +410 -0
  21. data/fixtures/vcr_cassettes/TestHudsonJob_test_create.yml +257 -0
  22. data/fixtures/vcr_cassettes/TestHudsonJob_test_desc_update.yml +281 -0
  23. data/fixtures/vcr_cassettes/TestHudsonJob_test_get.yml +191 -0
  24. data/fixtures/vcr_cassettes/TestHudsonJob_test_job_with_spaces.yml +260 -0
  25. data/fixtures/vcr_cassettes/TestHudsonJob_test_list.yml +39 -0
  26. data/fixtures/vcr_cassettes/TestHudsonJob_test_list_active.yml +39 -0
  27. data/fixtures/vcr_cassettes/TestHudsonJob_test_new.yml +561 -0
  28. data/fixtures/vcr_cassettes/TestHudsonJob_test_scm_url.yml +728 -0
  29. data/fixtures/vcr_cassettes/TestHudsonJob_test_triggers_delete.yml +588 -0
  30. data/fixtures/vcr_cassettes/TestHudsonJob_test_triggers_set.yml +346 -0
  31. data/fixtures/vcr_cassettes/TestHudsonJob_test_triggers_set_using_shortcut.yml +346 -0
  32. data/fixtures/vcr_cassettes/TestHudsonJob_test_url.yml +156 -0
  33. data/fixtures/vcr_cassettes/TestHudsonJob_test_wipe_out_workspace.yml +685 -0
  34. data/hudson-remote-api.gemspec +23 -0
  35. data/lib/hudson-remote-api.rb +3 -128
  36. data/lib/hudson-remote-api/build.rb +18 -35
  37. data/lib/hudson-remote-api/build_queue.rb +13 -20
  38. data/lib/hudson-remote-api/client.rb +179 -0
  39. data/lib/hudson-remote-api/hudson_xml_api.rb +61 -0
  40. data/lib/hudson-remote-api/job.rb +207 -345
  41. data/lib/hudson-remote-api/parser/build_info.rb +37 -0
  42. data/lib/hudson-remote-api/parser/build_queue_info.rb +19 -0
  43. data/lib/hudson-remote-api/parser/job_config_info.rb +99 -0
  44. data/lib/hudson-remote-api/parser/job_info.rb +62 -0
  45. data/lib/hudson-remote-api/parser/multicast.rb +28 -0
  46. data/lib/hudson-remote-api/parser/server_info.rb +49 -0
  47. data/lib/hudson-remote-api/settings.rb +31 -0
  48. data/lib/hudson-remote-api/version.rb +3 -0
  49. data/lib/hudson-remote-api/xml_writer/job_config_info.rb +113 -0
  50. data/test/test_helper.rb +10 -0
  51. data/test/test_hudson_build.rb +28 -0
  52. data/test/test_hudson_build_queue.rb +11 -0
  53. data/test/test_hudson_client.rb +65 -0
  54. data/test/test_hudson_job.rb +162 -0
  55. data/test/test_hudson_multicast.rb +9 -0
  56. data/test/test_hudson_settings.rb +70 -0
  57. metadata +71 -53
  58. data/lib/hudson-remote-api/config.rb +0 -46
@@ -1,348 +1,210 @@
1
1
  module Hudson
2
- # This class provides an interface to Hudson jobs
3
- class Job < HudsonObject
4
- attr_accessor :name, :config, :repository_url, :repository_urls, :repository_browser_location, :description, :parameterized_job
5
-
6
- SVN_SCM_CONF = <<-SVN_SCM_STRING
7
- <scm class="hudson.scm.SubversionSCM">
8
- <locations>
9
- <hudson.scm.SubversionSCM_-ModuleLocation>
10
- <remote>%s</remote>
11
- <local>.</local>
12
- </hudson.scm.SubversionSCM_-ModuleLocation>
13
- </locations>
14
- <excludedRegions/>
15
- <includedRegions/>
16
- <excludedUsers/>
17
- <excludedRevprop/>
18
- <excludedCommitMessages/>
19
- <workspaceUpdater class="hudson.scm.subversion.UpdateUpdater"/>
20
- </scm>
21
- SVN_SCM_STRING
22
-
23
- # Class methods
24
- class <<self
25
- # List all Hudson jobs
26
- def list()
27
- xml = get_xml(@@hudson_xml_api_path)
28
-
29
- jobs = []
30
- jobs_doc = REXML::Document.new(xml)
31
- jobs_doc.each_element("hudson/job") do |job|
32
- jobs << job.elements["name"].text
33
- end
34
- jobs
35
- end
36
-
37
- # List all jobs in active execution
38
- def list_active
39
- xml = get_xml(@@hudson_xml_api_path)
40
-
41
- active_jobs = []
42
- jobs_doc = REXML::Document.new(xml)
43
- jobs_doc.each_element("hudson/job") do |job|
44
- if job.elements["color"].text.include?("anime")
45
- active_jobs << job.elements["name"].text
46
- end
47
- end
48
- active_jobs
49
- end
50
-
51
- def get(job_name)
52
- job_name.strip!
53
- list.include?(job_name) ? Job.new(job_name) : nil
54
- end
55
-
56
- def create(name, config=nil)
57
- config ||= File.open(File.dirname(__FILE__) + '/new_job_config.xml').read
58
-
59
- response = send_post_request(@@xml_api_create_item_path, {:name=>name, :mode=>"hudson.model.FreeStyleProject", :config=>config})
60
- raise(APIError, "Error creating job #{name}: #{response.body}") if response.class != Net::HTTPFound
61
- Job.get(name)
62
- end
63
-
64
- end
65
-
66
- # Instance methods
67
- def initialize(name, config=nil)
68
- name.strip!
69
- Hudson::Job.fetch_crumb
70
- # Creates the job in Hudson if it doesn't already exist
71
- @name = Job.list.include?(name) ? name : Job.create(name, config).name
72
- load_xml_api
73
- load_config
74
- self
75
- end
76
-
77
- def load_xml_api
78
- @xml_api_path = File.join(Hudson[:url], "job/#{@name}/api/xml")
79
- @xml_api_config_path = File.join(Hudson[:url], "job/#{@name}/config.xml")
80
- @xml_api_build_path = File.join(Hudson[:url], "job/#{@name}/build")
81
- @xml_api_build_with_params_path = File.join(Hudson[:url], "job/#{@name}/buildWithParameters")
82
- @xml_api_disable_path = File.join(Hudson[:url], "job/#{@name}/disable")
83
- @xml_api_enable_path = File.join(Hudson[:url], "job/#{@name}/enable")
84
- @xml_api_delete_path = File.join(Hudson[:url], "job/#{@name}/doDelete")
85
- @xml_api_wipe_out_workspace_path = File.join(Hudson[:url], "job/#{@name}/doWipeOutWorkspace")
86
- end
87
-
88
- # Load data from Hudson's Job configuration settings into class variables
89
- def load_config
90
- @config = get_xml(@xml_api_config_path)
91
- @config_doc = REXML::Document.new(@config)
92
-
93
- @info = get_xml(@xml_api_path)
94
- @info_doc = REXML::Document.new(@info)
95
-
96
- @repository_urls = []
97
- if @config_doc.elements["/project/description"]
98
- @description = @config_doc.elements["/project/description"].text || ""
99
- end
100
-
101
- @parameterized_job = false
102
- if @config_doc.elements["/project/properties/hudson.model.ParametersDefinitionProperty"]
103
- @parameterized_job = true
104
- end
105
-
106
- if @config_doc.elements["/project/scm"].attributes['class'] == "hudson.plugins.git.GitSCM"
107
- @git = true
108
- @repository_url = {}
109
- if @config_doc.elements["/project/scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/url"]
110
- @repository_url[:url] = @config_doc.elements['/project/scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/url'].text || ""
111
- end
112
- if @config_doc.elements['/project/scm/branches/hudson.plugins.git.BranchSpec/name']
113
- @repository_url[:branch] = @config_doc.elements['/project/scm/branches/hudson.plugins.git.BranchSpec/name'].text || ""
114
- end
115
- if @config_doc.elements['/project/scm/browser/url']
116
- @repository_browser_location = @config_doc.elements['/project/scm/browser/url'].text || ""
117
- end
118
- else
119
- if !@config_doc.elements["/project/scm/locations/hudson.scm.SubversionSCM_-ModuleLocation/remote"].nil?
120
- @repository_url = @config_doc.elements["/project/scm/locations/hudson.scm.SubversionSCM_-ModuleLocation/remote"].text || ""
121
- end
122
- if !@config_doc.elements["/project/scm/locations"].nil?
123
- @config_doc.elements.each("/project/scm/locations/hudson.scm.SubversionSCM_-ModuleLocation"){|e| @repository_urls << e.elements["remote"].text }
124
- end
125
- if !@config_doc.elements["/project/scm/browser/location"].nil?
126
- @repository_browser_location = @config_doc.elements["/project/scm/browser/location"].text
127
- end
128
- end
129
- end
130
-
131
- def free_style_project?
132
- !@info_doc.elements["/freeStyleProject"].nil?
133
- end
134
-
135
- def color
136
- @info_doc.elements["/freeStyleProject/color"].text if free_style_project? && @info_doc.elements["/freeStyleProject/color"]
137
- end
138
-
139
- def last_build
140
- @info_doc.elements["/freeStyleProject/lastBuild/number"].text if free_style_project? && @info_doc.elements["/freeStyleProject/lastBuild/number"]
141
- end
142
-
143
- def last_completed_build
144
- @info_doc.elements["/freeStyleProject/lastCompletedBuild/number"].text if free_style_project? && @info_doc.elements["/freeStyleProject/lastCompletedBuild/number"]
145
- end
146
-
147
- def last_failed_build
148
- @info_doc.elements["/freeStyleProject/lastFailedBuild/number"].text if free_style_project? && @info_doc.elements["/freeStyleProject/lastFailedBuild/number"]
149
- end
150
-
151
- def last_stable_build
152
- @info_doc.elements["/freeStyleProject/lastStableBuild/number"].text if free_style_project? && @info_doc.elements["/freeStyleProject/lastStableBuild/number"]
153
- end
154
-
155
- def last_successful_build
156
- @info_doc.elements["/freeStyleProject/lastSuccessfulBuild/number"].text if free_style_project? && @info_doc.elements["/freeStyleProject/lastSuccessfulBuild/number"]
157
- end
158
-
159
- def last_unsuccessful_build
160
- @info_doc.elements["/freeStyleProject/lastUnsuccessfulBuild/number"].text if free_style_project? && @info_doc.elements["/freeStyleProject/lastUnsuccessfulBuild/number"]
161
- end
162
-
163
- def next_build_number
164
- @info_doc.elements["/freeStyleProject/nextBuildNumber"].text if free_style_project? && @info_doc.elements["/freeStyleProject/nextBuildNumber"]
165
- end
166
-
167
- def builds_list
168
- builds_list = []
169
- @info_doc.elements.each("/freeStyleProject/build"){|e| builds_list << e.elements["number"].text } unless @info_doc.elements["/freeStyleProject/build"].nil?
170
- builds_list
171
- end
172
-
173
- def active?
174
- Job.list_active.include?(@name)
175
- end
176
-
177
- def wait_for_build_to_finish(poll_freq=10)
178
- loop do
179
- puts "waiting for all #{@name} builds to finish"
180
- sleep poll_freq # wait
181
- break if !active? and !BuildQueue.list.include?(@name)
182
- end
183
- end
184
-
185
- # Create a new job on Hudson server based on the current job object
186
- def copy(new_job=nil)
187
- new_job = "copy_of_#{@name}" if new_job.nil?
188
-
189
- response = send_post_request(@@xml_api_create_item_path, {:name=>new_job, :mode=>"copy", :from=>@name})
190
- raise(APIError, "Error copying job #{@name}: #{response.body}") if response.class != Net::HTTPFound
191
- Job.new(new_job)
192
- end
193
-
194
- # Update the job configuration on Hudson server
195
- def update(config=nil)
196
- @config = config if !config.nil?
197
- response = send_xml_post_request(@xml_api_config_path, @config)
198
- response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
199
- end
200
-
201
- # Set the repository url and update on Hudson server
202
- def repository_url=(repository_url)
203
- #return false if @repository_url.nil?
204
-
205
- @repository_url = repository_url
206
-
207
- if @git
208
- if repository_url[:url]
209
- @config_doc.elements['/project/scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/url'].text = repository_url[:url]
210
- end
211
- if repository_url[:branch]
212
- @config_doc.elements['/project/scm/branches/hudson.plugins.git.BranchSpec/name'].text = repository_url[:branch]
213
- end
214
- else
215
- if @config_doc.elements["/project/scm"].attributes['class'] == "hudson.scm.NullSCM"
216
- @config_doc.elements["/project/scm"].replace_with REXML::Document.new(SVN_SCM_CONF % repository_url)
217
- else
218
- @config_doc.elements["/project/scm/locations/hudson.scm.SubversionSCM_-ModuleLocation/remote"].text = repository_url
219
- end
220
- end
221
-
222
- @config = @config_doc.to_s
223
- update
224
- end
225
-
226
- def repository_urls=(repository_urls)
227
- return false if !repository_urls.class == Array
228
- @repository_urls = repository_urls
229
-
230
- i = 0
231
- @config_doc.elements.each("/project/scm/locations/hudson.scm.SubversionSCM_-ModuleLocation") do |location|
232
- location.elements["remote"].text = @repository_urls[i]
233
- i += 1
234
- end
235
-
236
- @config = @config_doc.to_s
237
- update
238
- end
239
-
240
- # Set the repository browser location and update on Hudson server
241
- def repository_browser_location=(repository_browser_location)
242
- @repository_browser_location = repository_browser_location
243
- if @git
244
- @config_doc.elements['/project/scm/browser/url'].text = repository_browser_location
245
- else
246
- @config_doc.elements["/project/scm/browser/location"].text = repository_browser_location
247
- end
248
- @config = @config_doc.to_s
249
- update
250
- end
251
-
252
- # Set the job description and update on Hudson server
253
- def description=(description)
254
- @description = description
255
- @config_doc.elements["/project"] << REXML::Element.new("description") if @config_doc.elements["/project/description"].nil?
256
-
257
- @config_doc.elements["/project/description"].text = description
258
- @config = @config_doc.to_s
259
- update
260
- end
261
-
262
- def generate_trigger trigger, spec_text
263
- spec = REXML::Element.new("spec")
264
- spec.text = spec_text.to_s
265
- trigger.elements << spec
266
- trigger
267
- end
268
- private :generate_trigger
269
-
270
- def triggers= opts={}
271
- opts = {} if opts.nil?
272
- if triggers = @config_doc.elements["/project/triggers[@class='vector']"]
273
- triggers.elements.delete_all '*'
274
- opts.each do |key, value|
275
- trigger_name = key.to_s
276
- trigger_name = 'hudson.triggers.' + trigger_name unless Regexp.new(/^hudson\.triggers\./).match(trigger_name)
277
- if trigger = triggers.elements[trigger_name]
278
- if spec = trigger.elements['spec']
279
- spec.text = value.to_s
280
- else
281
- triggers.elements << generate_trigger(trigger, value)
282
- end
283
- else
284
- triggers.elements << generate_trigger(REXML::Element.new(trigger_name), value)
285
- end
286
- end
287
- # Todo: before calling update, @config need to be assigned with @config_doc.to_s,
288
- # let it be done by update.
289
- @config = @config_doc.to_s
290
- update
291
- else
292
- $stderr.puts "triggers not found in configuration, triggers assignment ignored."
293
- end
294
- end
295
-
296
- def triggers
297
- results = {}
298
- if triggers = @config_doc.elements["/project/triggers[@class='vector']"]
299
- triggers.elements.to_a.each do |trigger|
300
- spec_text = trigger.elements['spec'].text
301
- results[trigger.name.to_s] = spec_text.to_s
302
- end
303
- end
304
- results
305
- end
306
-
307
- def url
308
- File.join( Hudson[:url], 'job', name) + '/'
309
- end
310
-
311
- # Start building this job on Hudson server
312
- def build(params={})
313
- if @parameterized_job
314
- response = send_post_request(@xml_api_build_with_params_path, {:delay => '0sec'}.merge(params))
315
- else
316
- response = send_post_request(@xml_api_build_path, {:delay => '0sec'})
317
- end
318
- response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
319
- end
320
-
321
- def disable()
322
- response = send_post_request(@xml_api_disable_path)
323
- response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
324
- end
325
-
326
- def enable()
327
- response = send_post_request(@xml_api_enable_path)
328
- response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
329
- end
330
-
331
- # Delete this job from Hudson server
332
- def delete()
333
- response = send_post_request(@xml_api_delete_path)
334
- response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
335
- end
336
-
337
- def wipe_out_workspace()
338
- wait_for_build_to_finish
339
-
340
- if !active?
341
- response = send_post_request(@xml_api_wipe_out_workspace_path)
342
- else
343
- response = false
344
- end
345
- response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
346
- end
2
+ # This class provides an interface to Hudson jobs
3
+ class Job
4
+ attr_accessor :name, :config, :repository_url, :repository_urls, :repository_browser_location, :description, :parameterized_job
5
+
6
+ # Class methods
7
+ class <<self
8
+ # List all Hudson jobs
9
+ def list()
10
+ xml = Hudson.client.server_info
11
+ server_info_parser = Hudson::Parser::ServerInfo.new(xml)
12
+
13
+ server_info_parser.jobs
14
+ end
15
+
16
+ # List all jobs in active execution
17
+ def list_active
18
+ xml = Hudson.client.server_info
19
+ server_info_parser = Hudson::Parser::ServerInfo.new(xml)
20
+
21
+ server_info_parser.active_jobs
22
+ end
23
+
24
+ def get(job_name)
25
+ job_name.strip!
26
+ list.include?(job_name) ? Job.new(job_name) : nil
27
+ end
28
+
29
+ def create(name, config=nil)
30
+ config ||= File.open(File.dirname(__FILE__) + '/new_job_config.xml').read
31
+ response = Hudson.client.create_item!({:name=>name, :mode=>"hudson.model.FreeStyleProject", :config=>config})
32
+ raise(APIError, "Error creating job #{name}: #{response.body}") if response.class != Net::HTTPFound
33
+ Job.get(name)
34
+ end
35
+
36
+ end
37
+
38
+ # Instance methods
39
+ def initialize(name, config=nil)
40
+ name.strip!
41
+ # Creates the job in Hudson if it doesn't already exist
42
+ @name = Job.list.include?(name) ? name : Job.create(name, config).name
43
+ load_config
44
+ self
45
+ end
46
+
47
+ # Load data from Hudson's Job configuration settings into class variables
48
+ def load_config
49
+ @config = Hudson.client.job_config_info(self.name)
50
+ @config_info_parser = Hudson::Parser::JobConfigInfo.new(@config)
51
+ @config_writer = Hudson::XmlWriter::JobConfigInfo.new(self.name, @config)
52
+
53
+ @info = Hudson.client.job_info(self.name)
54
+ @job_info_parser = Hudson::Parser::JobInfo.new(@info)
55
+
56
+ @description = @config_info_parser.description
57
+ @parameterized_job = @config_info_parser.parameterized?
58
+ @git = @config_info_parser.git_repo?
59
+ @repository_url = @git ? @config_info_parser.git_repository : @config_info_parser.svn_repository
60
+ @repostory_urls = @config_info_parser.svn_repository_urls
61
+ @repository_browser_location = @config_info_parser.scm_broswer_location
62
+ end
63
+ alias :reload_config :load_config
64
+
65
+ def free_style_project?
66
+ @free_style_project ||= @job_info_parser.free_style_project?
67
+ end
68
+
69
+ def color
70
+ @color ||= @job_info_parser.color
71
+ end
72
+
73
+ def last_build
74
+ @job_info_parser.last_build
75
+ end
76
+
77
+ def last_completed_build
78
+ @job_info_parser.last_completed_build
79
+ end
80
+
81
+ def last_failed_build
82
+ @job_info_parser.last_failed_build
83
+ end
84
+
85
+ def last_stable_build
86
+ @job_info_parser.last_stable_build
87
+ end
88
+
89
+ def last_successful_build
90
+ @job_info_parser.last_successful_build
91
+ end
92
+
93
+ def last_unsuccessful_build
94
+ @job_info_parser.last_unsuccessful_build
95
+ end
96
+
97
+ def next_build_number
98
+ @job_info_parser.next_build_number
99
+ end
100
+
101
+ def builds_list
102
+ @job_info_parser.builds
103
+ end
104
+
105
+ def active?
106
+ Job.list_active.include?(self.name)
107
+ end
108
+
109
+ def wait_for_build_to_finish(poll_freq=10)
110
+ loop do
111
+ puts "waiting for all #{@name} builds to finish"
112
+ sleep poll_freq # wait
113
+ break if !active? and !BuildQueue.list.include?(@name)
114
+ end
115
+ end
116
+
117
+ # Create a new job on Hudson server based on the current job object
118
+ def copy(new_job=nil)
119
+ new_job = "copy_of_#{@name}" if new_job.nil?
120
+ response = Hudson.client.create_item!({:name=>new_job, :mode=>"copy", :from=>@name})
121
+ raise(APIError, "Error copying job #{@name}: #{response.body}") if response.class != Net::HTTPFound
122
+ Job.new(new_job)
123
+ end
124
+
125
+ # Set the repository url and update on Hudson server
126
+ def repository_url=(repository_url)
127
+ #return false if @repository_url.nil?
128
+ if @git
129
+ @config_writer.git_repository_url = repository_url
130
+ else
131
+ @config_writer.svn_repository_url = repository_url
132
+ end
133
+ reload_config
134
+ end
135
+
136
+ def repository_urls=(repository_urls)
137
+ @config_writer.repository_urls = repository_urls
138
+ reload_config
139
+ end
140
+
141
+ # Set the repository browser location and update on Hudson server
142
+ def repository_browser_location=(repository_browser_location)
143
+ if @git
144
+ @config_writer.git_repository_browser_location = repository_browser_location
145
+ else
146
+ @config_writer.svn_repository_browser_location = repository_browser_location
147
+ end
148
+ reload_config
149
+ end
150
+
151
+ # Set the job description and update on Hudson server
152
+ def description=(description)
153
+ @config_writer.description = description
154
+ reload_config
155
+ end
156
+
157
+ def triggers= opts={}
158
+ @config_writer.triggers = opts
159
+ reload_config
160
+ end
161
+
162
+ def triggers
163
+ @config_info_parser.triggers
164
+ end
165
+
166
+ #def url
167
+ # File.join( Hudson[:url], 'job', self.name) + '/'
168
+ #end
169
+
170
+ # Start building this job on Hudson server
171
+ def build(params={})
172
+ if @parameterized_job
173
+ response = Hudson.client.build_job_with_parameters!(self.name, params)
174
+ else
175
+ response = Hudson.client.build_job!(self.name)
176
+ end
177
+ response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
178
+ end
179
+
180
+ def disable()
181
+ response = Hudson.client.disable_job!(self.name)
182
+ response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
183
+ end
184
+
185
+ def enable()
186
+ response = Hudson.client.enable_job!(self.name)
187
+ response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
347
188
  end
189
+
190
+ # Delete this job from Hudson server
191
+ def delete()
192
+ response = Hudson.client.delete_job!(self.name)
193
+ response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
194
+ end
195
+
196
+ def wipe_out_workspace()
197
+ wait_for_build_to_finish
198
+
199
+ if !active?
200
+ response = Hudson.client.wipeout_job_workspace!(self.name)
201
+ else
202
+ response = false
203
+ end
204
+ response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
205
+ end
206
+
207
+
208
+
209
+ end
348
210
  end