Class: Jenkins2API::Endpoint::Job
- Inherits:
-
BaseEndpoint
- Object
- BaseEndpoint
- Jenkins2API::Endpoint::Job
- Defined in:
- lib/endpoints/job.rb
Overview
This class contains all the calls to reach Jenkins2 and obtain Build data
Instance Method Summary collapse
-
#build(name, parameters = {}, delay = 0) ⇒ Object
Trigger a build on a specific job.
-
#builds(name) ⇒ Object
(also: #get_builds)
Get all available builds for a specific job.
-
#get_test_results(name, build_id) ⇒ Object
Get test results “alias” Why? Because jenkins1 api gem uses this logic Why? I don’t know.
-
#jobs(name) ⇒ Object
Get all available sub-jobs for a specific job.
-
#list ⇒ Object
Lists all available jobs.
Methods inherited from BaseEndpoint
Constructor Details
This class inherits a constructor from Jenkins2API::Endpoint::BaseEndpoint
Instance Method Details
#build(name, parameters = {}, delay = 0) ⇒ Object
Trigger a build on a specific job
Params:
name
-
Name of the job
parameters
-
Hash with build parameters,
key => valule pairs
delay
-
Delay the build in seconds
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/endpoints/job.rb', line 51 def build(name, parameters = {}, delay = 0) post = { parameter: [] } parameters.each do |key, value| post[:parameter] << { name: key, value: value } end @client.api_request( :post, "/job/#{name}/build?delay=#{delay}sec", :raw, json: post.to_json ) end |
#builds(name) ⇒ Object Also known as: get_builds
Get all available builds for a specific job
Params:
name
-
Name of the Job
Returns with an array of builds
30 31 32 |
# File 'lib/endpoints/job.rb', line 30 def builds(name) @client.api_request(:get, "/job/#{name}")['builds'] end |
#get_test_results(name, build_id) ⇒ Object
Get test results “alias” Why? Because jenkins1 api gem uses this logic Why? I don’t know.
Params:
name
-
Name of the Job
build_id
-
ID of the build
20 21 22 |
# File 'lib/endpoints/job.rb', line 20 def get_test_results(name, build_id) @client.build.test_results(name, build_id) end |
#jobs(name) ⇒ Object
Get all available sub-jobs for a specific job
Params:
name
-
Name of the Job
Returns with an array of jobs
40 41 42 |
# File 'lib/endpoints/job.rb', line 40 def jobs(name) @client.api_request(:get, "/job/#{name}")['jobs'] end |
#list ⇒ Object
Lists all available jobs
9 10 11 |
# File 'lib/endpoints/job.rb', line 9 def list @client.api_request(:get, '')['jobs'] end |