Class: TeamCityClient
- Inherits:
-
Object
- Object
- TeamCityClient
- Defined in:
- lib/teamcity-client.rb
Overview
Team City HTTP client.
Authentication is not yet supported and therefore guest access is required.
Currently supports retrieving the number of new build errors for a given build.
Initialize with a host:port string for grabbing and parsing pages in the Team City interface.
Constant Summary collapse
- VERSION =
"0.0.3"
Instance Method Summary collapse
- #build_errors(build_id, show_progress = true) ⇒ Object
-
#initialize(host) ⇒ TeamCityClient
constructor
A new instance of TeamCityClient.
Constructor Details
#initialize(host) ⇒ TeamCityClient
Returns a new instance of TeamCityClient.
19 20 21 |
# File 'lib/teamcity-client.rb', line 19 def initialize(host) @host = host end |
Instance Method Details
#build_errors(build_id, show_progress = true) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/teamcity-client.rb', line 23 def build_errors(build_id, show_progress=true) # Grab the build page for the given build ID and parse the page # for amount of time left for the build to complete. Keep hitting # the page until the build is complete and output the amout of time # remaining. Once the build is complete, parse the page for any # new errors and return the number. begin html = RestClient.get("http://#{@host}/viewLog.html?buildId=#{build_id}&guest=1") doc = Nokogiri::HTML(html) parts = doc.css(".statusTable").text.split("Time left:") time_left = parts.length > 1 ? parts[1].split("(")[0].gsub(/\s+/, "") : "" if show_progress && !time_left.empty? STDOUT.write "\rTime left: #{time_left} (CTRL-C to abort)" STDOUT.flush end sleep 1 end until time_left.empty? doc.css(".failCount strong").text.to_i end |