class Jenkins2API::Endpoint::Build
This class contains all the calls to reach Jenkins2 and obtain Build
data
Public Instance Methods
get(job_name, build_id)
click to toggle source
latest(name)
click to toggle source
logtext_lines(name, build_id)
click to toggle source
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
# 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)
click to toggle source
Get the name of the slave where the build was executed
Params:¶ ↑
name
-
Name of the
Job
build_id
-
ID of the build
# 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
Private Instance Methods
find_line(lines, expression)
click to toggle source
find the first item in a string array that matches for a given regular expression
# File lib/endpoints/build.rb, line 73 def find_line(lines, expression) lines.select { |line| line.match(expression) }.first end
first_match(line, expression)
click to toggle source
return the first capture block from a string that matches for a given regular expression
# File lib/endpoints/build.rb, line 79 def first_match(line, expression) line.match(expression).captures.first rescue nil end