我正在使用 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' }
}
)