Class: Jenkins2API::Endpoint::Build
- Inherits:
-
BaseEndpoint
- Object
- BaseEndpoint
- Jenkins2API::Endpoint::Build
- Defined in:
- lib/endpoints/build.rb
Overview
This class contains all the calls to reach Jenkins2 and obtain Build data
Instance Method Summary collapse
-
#get(job_name, build_id) ⇒ Object
Get a specific build.
-
#latest(name) ⇒ Object
Get the latest build.
-
#logtext_lines(name, build_id) ⇒ Object
Get console log for a specific build as text.
-
#slave_name(name, build_id) ⇒ Object
Get the name of the slave where the build was executed.
-
#test_results(name, build_id) ⇒ Object
Get test report for a specific build.
Methods inherited from BaseEndpoint
Constructor Details
This class inherits a constructor from Jenkins2API::Endpoint::BaseEndpoint
Instance Method Details
#get(job_name, build_id) ⇒ Object
Get a specific build
Params:
job_name
-
Name of the Job
build_id
-
ID of the build
13 14 15 |
# File 'lib/endpoints/build.rb', line 13 def get(job_name, build_id) @client.api_request(:get, "/job/#{job_name}/#{build_id}") end |
#latest(name) ⇒ Object
Get the latest build
Params:
job_name
-
Name of the Job
21 22 23 |
# File 'lib/endpoints/build.rb', line 21 def latest(name) @client.api_request(:get, "/job/#{name}/lastBuild") end |
#logtext_lines(name, build_id) ⇒ Object
Get console log for a specific build as text
Params:
job_name
-
Name of the Job
build_id
-
ID of the build
Return an array of strings. Each item in that array is a line from the log
42 43 44 45 46 47 48 |
# File 'lib/endpoints/build.rb', line 42 def logtext_lines(name, build_id) @client.api_request( :get, "/job/#{name}/#{build_id}/logText/progressiveText", :raw ).split("\r\n") end |
#slave_name(name, build_id) ⇒ Object
Get the name of the slave where the build was executed
Params:
name
-
Name of the Job
build_id
-
ID of the build
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/endpoints/build.rb', line 55 def slave_name(name, build_id) log = logtext_lines(name, build_id) line = find_line(log, /^Running on /) name = first_match(line, %r{^Running on (.*) in /}) if name.nil? line = find_line(log, /Building remotely on/) name = first_match(line, /Building remotely on (.*) in workspace/) end name end |
#test_results(name, build_id) ⇒ Object
Get test report for a specific build
Params:
name
-
Name of the Job
build_id
-
ID of the build
30 31 32 |
# File 'lib/endpoints/build.rb', line 30 def test_results(name, build_id) @client.api_request(:get, "/job/#{name}/#{build_id}/testReport", :xml) end |