Class: Jbcm::Client::Job
- Inherits:
-
Object
- Object
- Jbcm::Client::Job
- Defined in:
- lib/jbcm.rb
Instance Attribute Summary collapse
-
#cli ⇒ Object
readonly
Returns the value of attribute cli.
-
#job_name ⇒ Object
readonly
Returns the value of attribute job_name.
Instance Method Summary collapse
- #build_command ⇒ Object
- #build_command=(build_command) ⇒ Object
- #config ⇒ Object
-
#initialize(cli, job_name = nil) ⇒ Job
constructor
A new instance of Job.
- #list(raw: false) ⇒ Object
- #update ⇒ Object
- #update! ⇒ Object
Constructor Details
#initialize(cli, job_name = nil) ⇒ Job
Returns a new instance of Job.
37 38 39 40 |
# File 'lib/jbcm.rb', line 37 def initialize(cli, job_name = nil) @cli = cli @job_name = job_name end |
Instance Attribute Details
#cli ⇒ Object (readonly)
Returns the value of attribute cli.
35 36 37 |
# File 'lib/jbcm.rb', line 35 def cli @cli end |
#job_name ⇒ Object (readonly)
Returns the value of attribute job_name.
35 36 37 |
# File 'lib/jbcm.rb', line 35 def job_name @job_name end |
Instance Method Details
#build_command ⇒ Object
55 56 57 |
# File 'lib/jbcm.rb', line 55 def build_command config.elements['project/builders/hudson.tasks.Shell/command'].text end |
#build_command=(build_command) ⇒ Object
59 60 61 |
# File 'lib/jbcm.rb', line 59 def build_command=(build_command) config.elements['project/builders/hudson.tasks.Shell/command'].text = build_command end |
#config ⇒ Object
51 52 53 |
# File 'lib/jbcm.rb', line 51 def config @config ||= REXML::Document.new(cli.conn.get("job/#{job_name}/config.xml").body) end |
#list(raw: false) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/jbcm.rb', line 42 def list(raw: false) response = cli.conn.get('api/json') if raw JSON.parse(response.body) else JSON.parse(response.body)['jobs'] end end |
#update ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/jbcm.rb', line 63 def update cli.conn.post do |req| req.url "job/#{job_name}/config.xml" req.headers['Content-Type'] = 'application/xml' req.body = config.to_s end end |
#update! ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/jbcm.rb', line 71 def update! request_result = update if request_result.status == 200 $stdout.puts 'update successfully.' else fail "Update failed! return #{request_result.status}" end end |