jenkins - Dashing (Ruby) Nokogiri LoadError -


i've been working on dashboard on dashing framework, , i'm trying make little crawler collect specific data on jenkins-ci, , pass number widget. here's crawler (it's stub, counts number of "p" elements on stub html page):

require 'nokogiri' require 'open-uri'  class activebuilds        def initialize()           @jenkins_page = nil           @build_count = nil       end        # !stub! gets jenkins page parse xml on nokogiri       @jenkins_page = nokogiri::html(open("http://localhost:80"))        # !stub! counts number of 'p' items found on page       @build_count = @jenkins_page.css("p").length        # !stub! returns amount of active builds       def amountofactivebuilds           return @build_count       end end 

and reference, not necessary, html page:

<!doctype html>  <html>    <head>  	<meta charset="utf-8">      <title>number stub | project</title>    </head>    <body>      <h1>test</h1>      <ul>  	   <!-- count these -->         <li> <div> <p>item 1 </div>         <li> <div> <p>item 2 </div>         <li> <div> <p>item 3 </div>         <li> <div> <p>item 4 </div>         <li> <div> <p>item 5 </div>             <!-- stop counting -->         <li> <div> item 6 </div>         <li> <div> item 7 </div>       </ul>     </body>  </html>

and now, jobs/sample.rb file dashing, modified (the thing matters builds/valuation stuff):

require './activebuilds.rb'  active_builds = activebuilds.new current_valuation = active_builds.amountofactivebuilds current_karma = 0  scheduler.every '2s'   last_valuation = current_valuation   last_karma     = current_karma   current_karma  = rand(200000)    send_event('valuation', { current: current_valuation, last: last_valuation })   send_event('karma', { current: current_karma, last: last_karma })   send_event('synergy', { value: rand(100) })  end 

the thing is, before had working, page on localhost, count number of "p" items , print on file, , dashing file read , display correctly, wasn't updating value on dashboard unless i'd restart it, defeats purpose of framework.

now errors:

when attempting compile sample.rb (the dashing file):

$ ruby sample.rb sample.rb:12:in '<main>': uninitialized constant scheduler (nameerror) 

when attempting run dashing server:

$ dashing start /home/yadayada/.rvm/gems/ruby-2.2.0/gems/backports-3.6.4/lib/backports/std_lib.rb:9:in 'require': cannot load such file -- nokogiri (loaderror) /home/yadayada/.rvm/gems/ruby-2.2.0/gems/backports-3.6.4/lib/backports/std_lib.rb:9:in 'require_with_backports' /home/yadayada/desktop/dashing/project/jobs/activebuilds.rb:2:in '<top (required)>' (...) 

i post html/css/coffescript components of number widget, believe problem lies on sample.rb, , number widget default.

in case code wasn't clear enough, i'm trying localhost page, count number of "p" items (later it'll active builds when switch jenkins, didn't switch yet because i'm dealing certificates), send on sample.rb, data , update every 2 seconds on dashboard display.

any suggestions welcome! in advance!

found solution:

uninstall/reinstall nokogiri gem (without sudo) put crawler lib folder , require inside jobs on job itself, placed scheduler function, this:

# job provides data of amount of active builds on jenkins using number widget    # updates every 2 seconds  scheduler.every '2s'      # invokes crawlers lib folder    dir[file.dirname(__file__) + '/lib/*rb'].each { |file| require file }        # create activebuilds reference    builds = activebuilds.new        # attributes amount of active builds current valuation    current_valuation = builds.get_amount_of_active_builds        # pass current valuation last present change percentage on dashboard    last_valuation = current_valuation      # sends values number widget (widget id valuation)    send_event('valuation', { current: current_valuation, last: last_valuation })  end


Popular posts from this blog