0

i'm working on monitoring my jira bugs with dashing and jira-ruby. I found this widget but i have an error, when i started dashing.

Here the error:

scheduler caught exception:   
JIRA::HTTPError
    /Users/users/.rvm/gems/ruby-2.2.4/gems/jira-ruby-1.1.3/lib/jira/request_client.rb:16:in `request'
    /Users/users/.rvm/gems/ruby-2.2.4/gems/jira-ruby-1.1.3/lib/jira/client.rb:213:in `request'
    /Users/users/.rvm/gems/ruby-2.2.4/gems/jira-ruby-1.1.3/lib/jira/client.rb:191:in `get'
    /Users/users/.rvm/gems/ruby-2.2.4/gems/jira-ruby-1.1.3/lib/jira/resource/issue.rb:64:in `jql'
    /Users/users/.rvm/gems/ruby-2.2.4/gems/jira-ruby-1.1.3/lib/jira/base_factory.rb:33:in `block (2 levels) in delegate_to_target_class'
    /Users/users/../../jobs/jira_number_of_issues_in_filter.rb:35:in `block (2 levels) in <top (required)>'
    /Users/users/.rvm/gems/ruby-2.2.4/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:230:in `call'
    /Users/users/.rvm/gems/ruby-2.2.4/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:230:in `trigger_block'
    /Users/users/.rvm/gems/ruby-2.2.4/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:204:in `block in trigger'
    /Users/users/.rvm/gems/ruby-2.2.4/gems/rufus-scheduler-2.0.24/lib/rufus/sc/scheduler.rb:430:in `call'
    /Users/users/.rvm/gems/ruby-2.2.4/gems/rufus-scheduler-2.0.24/lib/rufus/sc/scheduler.rb:430:in `block in trigger_job'

Here a copy on my ruby-script:

require 'jira-ruby'

JIRA_PROPS = {
  'url' => URI.parse("https://SSSSS/test"),
  'username' => 'user',
  'password' => 'passwd',
  'proxy_address' => nil,
  'proxy_port' => nil
}

# the key of this mapping must be a unique identifier for your jql filter, the according value must be the jql filter id or filter name that is used in Jira
filter_mapping = {
  'filter1' => { :filter => 'aaaa' }
}

jira_options = {
  :username => JIRA_PROPS['username'],
  :password => JIRA_PROPS['password'],
  :context_path => JIRA_PROPS['url'].path,
  :site => JIRA_PROPS['url'].scheme + "://" + JIRA_PROPS['url'].host,
  :auth_type => :basic,
  :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE,
  :use_ssl => JIRA_PROPS['url'].scheme == 'https' ? true : false,
  :proxy_address => JIRA_PROPS['proxy_address'],
  :proxy_port => JIRA_PROPS['proxy_port']
}

last_issues = Hash.new(0)

filter_mapping.each do |filter_data_id, filter|
  SCHEDULER.every '10s', :first_in => 0 do |job|
    last_number_issues = last_issues['filter_data_id']
    client = JIRA::Client.new(jira_options)
    puts client.Issue
    //next line is the 35, where the error comes
    current_number_issues = client.Issue.jql("filter in (\"#{filter[:filter]}\")").size <-- line 35
    last_issues['filter_data_id'] = current_number_issues
    send_event(filter_data_id, { current: current_number_issues, last: last_number_issues})
  end
end

I just added gem 'jira-ruby' in my Gemfile.

any ideas about this issue.

emoleumassi
  • 4,881
  • 13
  • 67
  • 93
  • Although not likely the culprit, you have a typo. You're missing an end quote here: 'password' => 'passwd, – HeyZiko Nov 16 '16 at 22:21
  • Also, can you identify the line numbers in your ruby? The error is on line 35, which looks like the line after "puts client.Issue"... but it's hard to confirm. – HeyZiko Nov 16 '16 at 22:22
  • @HeyZiko, the error is on the line 35, you has right. How can i fix them? There is no problem with the password quote, just an error by question's editing – emoleumassi Nov 17 '16 at 07:30
  • Ok so please edit the question to show which line is number 35, and what is the output of "puts client.Issue" – HeyZiko Nov 17 '16 at 14:01
  • What happens if you change this (\"#{filter[:filter]}\") to this ('#{filter[:filter]}'), just to simplify the string? Also please show the output of "puts filter" and "puts filter[:filter]" – HeyZiko Nov 17 '16 at 14:10
  • i changed the query and got the same error. Output puts filter {:filter=>"aaaa"}, puts filter[:filter] = aaaa – emoleumassi Nov 17 '16 at 14:26
  • Can you try the following? (1) Verify that the JQL works as expected in the UI. (2) Verify that the JQL works when directly doing a rest-api call to JIRA - either using (postman)[https://www.getpostman.com/] or building off (this example)[https://github.com/sumoheavy/jira-ruby/issues/177] – HeyZiko Nov 17 '16 at 16:25

1 Answers1

0

I would try moving your URL directly to the site definition in the jira_options value.

:site => 'http://jira.company.com:8080', 

Also try testing the JIRA-ruby library outside of dashing to determine your connection settings.

In my experience using the direct / non-proxied URL works better. YMMV.

jbrass
  • 941
  • 7
  • 26