Class: Hudson::Job
- Inherits:
-
HudsonBase
- Object
- HudsonBase
- Hudson::Job
- Defined in:
- lib/api/job.rb
Instance Attribute Summary collapse
-
#hudson_url ⇒ Object
readonly
Returns the value of attribute hudson_url.
-
#msg ⇒ Object
readonly
Returns the value of attribute msg.
Class Method Summary collapse
-
.create(jobname, config) ⇒ Object
Create a new hudson job.
-
.run(jobname) ⇒ Object
Perform a build.
-
.update(jobname, config) ⇒ Object
Update a hudson job.
Instance Method Summary collapse
-
#builds ⇒ Object
Return builds from this job.
-
#heathStatusDescription ⇒ Object
Return status of job.
-
#initialize(jobname) ⇒ Job
constructor
A new instance of Job.
-
#lastCompletedBuild ⇒ Object
Return the las complete build as a JobInstance.
Methods inherited from HudsonBase
send_post_request, send_xml_post_request
Constructor Details
#initialize(jobname) ⇒ Job
Returns a new instance of Job.
6 7 8 9 10 11 |
# File 'lib/api/job.rb', line 6 def initialize(jobname) @jobname = jobname @api_suffix = "/api/json" @module_url = "/job/" load end |
Instance Attribute Details
#hudson_url ⇒ Object (readonly)
Returns the value of attribute hudson_url.
4 5 6 |
# File 'lib/api/job.rb', line 4 def hudson_url @hudson_url end |
#msg ⇒ Object (readonly)
Returns the value of attribute msg.
4 5 6 |
# File 'lib/api/job.rb', line 4 def msg @msg end |
Class Method Details
.create(jobname, config) ⇒ Object
Create a new hudson job
35 36 37 38 |
# File 'lib/api/job.rb', line 35 def self.create(jobname, config) url = "#{Hudson[:url]}/createItem?name=#{jobname}" send_xml_post_request(url, config) end |
.run(jobname) ⇒ Object
Perform a build
47 48 49 50 |
# File 'lib/api/job.rb', line 47 def self.run(jobname) url = "#{Hudson[:url]}/job/#{jobname}/build" send_post_request(url) end |
.update(jobname, config) ⇒ Object
Update a hudson job
41 42 43 44 |
# File 'lib/api/job.rb', line 41 def self.update(jobname, config) url = "#{Hudson[:url]}/job/#{jobname}/config.xml" send_xml_post_request(url, config) end |
Instance Method Details
#builds ⇒ Object
Return builds from this job
30 31 32 |
# File 'lib/api/job.rb', line 30 def builds @msg.fetch("builds") end |
#heathStatusDescription ⇒ Object
Return status of job
14 15 16 17 18 19 20 |
# File 'lib/api/job.rb', line 14 def heathStatusDescription desc = String.new @msg.fetch("healthReport").each do |report| desc += report.fetch("description") end return desc end |
#lastCompletedBuild ⇒ Object
Return the las complete build as a JobInstance
24 25 26 27 |
# File 'lib/api/job.rb', line 24 def lastCompletedBuild id = @msg.fetch("lastCompletedBuild").fetch("number") JobInstance.new(@jobname, id) end |