Я пытаюсь интегрировать мое новое приложение с 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 => "noreply@XXXXX.XXX" #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 cannot be null, needs a value
. Использование драгоценного камня Jira4R отсутствует благодаря нашему использованию Ruby 1.9.2. Любая помощь приветствуется. Спасибо!