使用 jira-ruby Gem 创建问题时出现问题

问题描述 投票:0回答:1

我正在使用 jira-ruby 进行测试并在 Jira 中创建一个问题。但是,当我尝试创建问题时,我收到此错误:

/Users/xxx/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jira-ruby-2.3.0/lib/jira/http_error.rb:11:in `initialize': undefined method `presence' for "":String (NoMethodError)

      @message = response.try(:message).presence || response.try(:body)
                                       ^^^^^^^^^
Did you mean?  presence_in
        from /Users/xxx/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jira-ruby-2.3.0/lib/jira/request_client.rb:13:in `exception'
        from /Users/xxx/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jira-ruby-2.3.0/lib/jira/request_client.rb:13:in `raise'
        from /Users/xxx/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jira-ruby-2.3.0/lib/jira/request_client.rb:13:in `request'
        from /Users/xxx/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jira-ruby-2.3.0/lib/jira/client.rb:306:in `request'
        from /Users/xxx/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jira-ruby-2.3.0/lib/jira/client.rb:289:in `post'
        from /Users/xxx/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jira-ruby-2.3.0/lib/jira/base.rb:347:in `save!'
        from /Users/xxx/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jira-ruby-2.3.0/lib/jira/base.rb:361:in `save'
        from test.rb:23:in `<main>'

不太确定这意味着什么,我在网上没有找到任何有用的研究。我能够连接到 Jira 并撤回问题、评论等。

这是代码:

require 'jira-ruby'

api_token = 'xxxx'

options = {
  :site => 'https://jira3.cerner.com',
  :context_path => '',
  :default_headers => { 'Authorization' => "Bearer #{api_token}" },
  :auth_type => :basic
}

client = JIRA::Client.new(options)

issue = client.Issue.build
issue.save(
  'fields' => {
    'summary' => 'Test using Jira-ruby',
    'project' => { 'id' => '15112' },
    'issuetype' => { 'id' => '3' },
    'priority' => { 'id' => '3' },
    'components' => { 'id' => '85201' }
  }
)
ruby-on-rails ruby rubygems jira jira-rest-api
1个回答
0
投票

这是 jira-ruby 2.3.0(您正在使用的版本)中的一个已知问题,以防出现 HTTP 错误,并且已在最新版本 (3.0.0.beta1) 中修复。

因此,我相信您有两个选择继续前进:

  1. 将 jira-ruby 更新至 3.0.0.beta1

  1. 添加与他们添加的类似的修复:
require 'jira-ruby'
require 'active_support/core_ext/object'
© www.soinside.com 2019 - 2024. All rights reserved.