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_commnad=(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.project.builders.send('hudson.tasks.Shell').command.nodes end |
#build_commnad=(build_command) ⇒ Object
59 60 61 62 |
# File 'lib/jbcm.rb', line 59 def build_commnad=(build_command) config.project.builders.send('hudson.tasks.Shell').command.nodes.pop config.project.builders.send('hudson.tasks.Shell').command.nodes.push(build_command) end |
#config ⇒ Object
51 52 53 |
# File 'lib/jbcm.rb', line 51 def config @config ||= Ox.parse(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
64 65 66 67 68 69 70 |
# File 'lib/jbcm.rb', line 64 def update cli.conn.post do |req| req.url "job/#{job_name}/config.xml" req.headers['Content-Type'] = 'application/xml' req.body = Ox.dump(config) end end |
#update! ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/jbcm.rb', line 72 def update! request_result = update if request_result.status == 200 $stdout.puts 'update successfully.' else fail "Update failed! return #{request_result.status}" end end |