JIRA-Ruby_ scheduler捕获异常:JIRA :: HTTPError

时间:2016-11-16 14:11:32

标签: ruby rubygems jira-rest-api dashing

我正在使用dashing和jira-ruby来监控我的jira错误。我发现这个this example,但是当我开始潇洒时,我有一个错误。

这里的错误:

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

这是我的ruby脚本上的副本:

        var request = (HttpWebRequest)HttpWebRequest.Create(uri + data);
        var response = (HttpWebResponse)request.GetResponse();
        var reader = new StreamReader(response.GetResponseStream());

        PICKUPREQUESTRESPONSE PICKUPREQUESTRESPONSE = null;

        XmlSerializer serializer = new XmlSerializer(typeof(PICKUPREQUESTRESPONSE));


        PICKUPREQUESTRESPONSE = (PICKUPREQUESTRESPONSE)serializer.Deserialize(reader);
        reader.Close();

我刚刚添加了gem&#39; jira-ruby&#39;在我的Gemfile中。

有关此问题的任何想法。

1 个答案:

答案 0 :(得分:0)

我会尝试将您的URL直接移动到jira_options值中的网站定义。

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

也请尝试在破折号之外测试JIRA-ruby库,以确定您的连接设置。

以我的经验,使用直接/非代理URL效果更好。 YMMV。