吉拉 +萨翁+红宝石问题
我正在尝试将我的新应用程序与 JIRA 集成,以管理客户的支持票证。我设想系统所做的是在 before_filter 中从 JIRA 中收集用户帐户 - 从中我可以提取帐户列表以及没有的帐户列表,如果他们没有帐户列表,那么我们根据他们的详细信息创建一个帐户Rails 应用程序。问题是,我在做一些事情时遇到了重大问题,例如从 jira-users 组中删除用户并将其添加到我为客户创建的名为客户支持的单独组中。这是我当前拥有的代码:
def current_jira_user
# Fetch the current user in JIRA, if we don't exist, create it!
user_try = @jira.request :get_user do |soap|
soap.body = { :token => @token, :username => "#{current_user.username}" }
end
if user_try.to_hash[:get_user_response][:get_user_return][:href].nil?
# We need to create the user
@jira.request :create_user do |soap|
soap.body = {
:token => @token,
:username => "#{current_user.username}",
:password => UUID.new.to_s,
:fullName => current_user.full_name,
:email => "[email protected]" #this is such a hack to get around JIRA's "you've got an account" email
}
end
new_user = RemoteUser.find(current_user.username)
@jira.request :remove_user_from_group do |soap|
soap.body = { :token => @token, :group => RemoteGroup.find('jira-users'), :ruser => new_user }
end
@jira.request :add_user_to_group do |soap|
soap.body = { :token => @token, :group => RemoteGroup.find('customer-support'), :ruser => new_user }
end
new_user[:email] = current_user.email
@jira.request :update_user do |soap| # change their email to the valid one
soap.body = { :token => @token, :ruser => new_user }
end
new_user
else
user_try.to_hash[:get_user_response][:get_user_return]
end
end
def verify_jira_connection
# Verify that we can reach the JIRA instance
@jira = Savon::Client.new do
wsdl.document = JIRA_SOAP_URI
end
@jira.http.read_timeout = 300
@jira.http.auth.ssl.verify_mode = :none
@auth = @jira.request :login do |soap|
soap.body = { :username => JIRA_LOGIN, :password => JIRA_PASSWORD }
end
@token = @auth.to_hash[:login_response][:login_return]
end
## REMOTE CLASSES
class RemoteUser
include Savon::Model
client do
http.headers["Pragma"] = "no-cache"
http.auth.ssl.verify_mode = :none
end
namespace "http://beans.soap.rpc.jira.atlassian.com"
endpoint JIRA_SOAP_URI
basic_auth JIRA_LOGIN, JIRA_PASSWORD
actions :get_user
def self.find(username)
get_user(:username => username).to_hash
end
end
class RemoteGroup
include Savon::Model
client do
http.headers["Pragma"] = "no-cache"
http.auth.ssl.verify_mode = :none
end
namespace "http://beans.soap.rpc.jira.atlassian.com"
endpoint JIRA_SOAP_URI
basic_auth JIRA_LOGIN, JIRA_PASSWORD
actions :get_group
def self.find(group)
get_group(:groupName => group).to_hash
end
end
用户创建得很好,但是当我进行removeUserFromGroup 调用时,我得到 (soapenv:Server.userException) com.atlassian.jira.rpc.exception.RemoteValidationException: group name can为 null,需要一个值
。由于我们使用了 Ruby 1.9.2,因此不再使用 Jira4R gem。任何帮助表示赞赏。谢谢!
I am trying to get my new application integrated with JIRA for management of our customer's support tickets. What I had envisioned the system doing was in a before_filter gathering a user's account from within JIRA - from that I can pull up a list of accounts and what not, and if they don't have one then we create one based on their details in the Rails application. Thing is I'm having major issues doing things like removing the user from the jira-users group and adding them to a separate group I have for customers called customer-support. This is the code I have currently:
def current_jira_user
# Fetch the current user in JIRA, if we don't exist, create it!
user_try = @jira.request :get_user do |soap|
soap.body = { :token => @token, :username => "#{current_user.username}" }
end
if user_try.to_hash[:get_user_response][:get_user_return][:href].nil?
# We need to create the user
@jira.request :create_user do |soap|
soap.body = {
:token => @token,
:username => "#{current_user.username}",
:password => UUID.new.to_s,
:fullName => current_user.full_name,
:email => "[email protected]" #this is such a hack to get around JIRA's "you've got an account" email
}
end
new_user = RemoteUser.find(current_user.username)
@jira.request :remove_user_from_group do |soap|
soap.body = { :token => @token, :group => RemoteGroup.find('jira-users'), :ruser => new_user }
end
@jira.request :add_user_to_group do |soap|
soap.body = { :token => @token, :group => RemoteGroup.find('customer-support'), :ruser => new_user }
end
new_user[:email] = current_user.email
@jira.request :update_user do |soap| # change their email to the valid one
soap.body = { :token => @token, :ruser => new_user }
end
new_user
else
user_try.to_hash[:get_user_response][:get_user_return]
end
end
def verify_jira_connection
# Verify that we can reach the JIRA instance
@jira = Savon::Client.new do
wsdl.document = JIRA_SOAP_URI
end
@jira.http.read_timeout = 300
@jira.http.auth.ssl.verify_mode = :none
@auth = @jira.request :login do |soap|
soap.body = { :username => JIRA_LOGIN, :password => JIRA_PASSWORD }
end
@token = @auth.to_hash[:login_response][:login_return]
end
## REMOTE CLASSES
class RemoteUser
include Savon::Model
client do
http.headers["Pragma"] = "no-cache"
http.auth.ssl.verify_mode = :none
end
namespace "http://beans.soap.rpc.jira.atlassian.com"
endpoint JIRA_SOAP_URI
basic_auth JIRA_LOGIN, JIRA_PASSWORD
actions :get_user
def self.find(username)
get_user(:username => username).to_hash
end
end
class RemoteGroup
include Savon::Model
client do
http.headers["Pragma"] = "no-cache"
http.auth.ssl.verify_mode = :none
end
namespace "http://beans.soap.rpc.jira.atlassian.com"
endpoint JIRA_SOAP_URI
basic_auth JIRA_LOGIN, JIRA_PASSWORD
actions :get_group
def self.find(group)
get_group(:groupName => group).to_hash
end
end
Users are created just fine, but when I get to the removeUserFromGroup call, I get (soapenv:Server.userException) com.atlassian.jira.rpc.exception.RemoteValidationException: group name cannot be null, needs a value
. Using the Jira4R gem is out thanks to our using Ruby 1.9.2. Any help is appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您需要明确发送名称?
如果您愿意进行一些重写
,您可以尝试使用与 Ruby 1.9 兼容的 jira4r 分支
Maybe you need to explicitly send the name?
instead of this
If you were willing to do some rewriting, you could try using a Ruby 1.9-compatible fork of jira4r